Skip to content

Commit 587e37f

Browse files
authored
Add setting to disable logging configuration (#1575)
1 parent 74ce257 commit 587e37f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/fastmcp/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
from fastmcp.utilities.logging import configure_logging as _configure_logging
77

88
settings = Settings()
9-
# if False:
10-
_configure_logging(
11-
level=settings.log_level,
12-
enable_rich_tracebacks=settings.enable_rich_tracebacks,
13-
)
9+
if settings.log_enabled:
10+
_configure_logging(
11+
level=settings.log_level,
12+
enable_rich_tracebacks=settings.enable_rich_tracebacks,
13+
)
1414

1515
from fastmcp.server.server import FastMCP
1616
from fastmcp.server.context import Context

src/fastmcp/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def settings(self) -> Self:
146146

147147
test_mode: bool = False
148148

149+
log_enabled: bool = True
149150
log_level: LOG_LEVEL = "INFO"
150151

151152
@field_validator("log_level", mode="before")
@@ -314,7 +315,7 @@ def normalize_log_level(cls, v):
314315
Whether to include FastMCP meta in the server's MCP responses.
315316
If True, a `_fastmcp` key will be added to the `meta` field of
316317
all MCP component responses. This key will contain a dict of
317-
various FastMCP-specific metadata, such as tags.
318+
various FastMCP-specific metadata, such as tags.
318319
"""
319320
),
320321
),

0 commit comments

Comments
 (0)