Commit 449f8ad
fix: configure only mcp namespace logger instead of root logger
FastMCP.__init__() calls configure_logging() which previously called
logging.basicConfig(), configuring the root logger with handlers and
level. This violates Python logging best practices: library code should
never configure the root logger, as that is the prerogative of the
application developer.
Replace logging.basicConfig() with targeted configuration of the 'mcp'
namespace logger only. This ensures:
- MCP SDK logs still work out of the box for quickstart scripts
- Application-level logging configuration is not overridden
- No duplicate handlers on repeated FastMCP instantiations
References:
- https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
Fixes #1656
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent cfe17d0 commit 449f8ad
1 file changed
Lines changed: 23 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
27 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
28 | 44 | | |
29 | 45 | | |
30 | 46 | | |
31 | 47 | | |
32 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
33 | 51 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 52 | + | |
| 53 | + | |
38 | 54 | | |
39 | | - | |
| 55 | + | |
0 commit comments