mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-28 10:18:08 +02:00
Compare commits
1 commit
main
...
claude/iss
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2702f5ad85 |
4 changed files with 21 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ if settings.log_enabled:
|
|||
_configure_logging(
|
||||
level=settings.log_level,
|
||||
enable_rich_tracebacks=settings.enable_rich_tracebacks,
|
||||
console_width=settings.rich_console_width,
|
||||
)
|
||||
|
||||
from fastmcp.server.server import FastMCP
|
||||
|
|
|
|||
|
|
@ -172,6 +172,19 @@ class Settings(BaseSettings):
|
|||
),
|
||||
] = True
|
||||
|
||||
rich_console_width: Annotated[
|
||||
int | None,
|
||||
Field(
|
||||
description=inspect.cleandoc(
|
||||
"""
|
||||
Width for Rich console output including tracebacks. If None,
|
||||
Rich will auto-detect the terminal width. Set to a larger value
|
||||
(e.g., 120, 140) for wider tracebacks that show more code context.
|
||||
"""
|
||||
)
|
||||
),
|
||||
] = 120
|
||||
|
||||
deprecation_warnings: Annotated[
|
||||
bool,
|
||||
Field(
|
||||
|
|
|
|||
|
|
@ -231,5 +231,8 @@ def log_server_banner(
|
|||
expand=False,
|
||||
)
|
||||
|
||||
console = Console(stderr=True)
|
||||
from fastmcp.settings import Settings
|
||||
|
||||
settings = Settings()
|
||||
console = Console(stderr=True, width=settings.rich_console_width)
|
||||
console.print(Group("\n", panel, "\n"))
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ def configure_logging(
|
|||
level: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] | int = "INFO",
|
||||
logger: logging.Logger | None = None,
|
||||
enable_rich_tracebacks: bool = True,
|
||||
console_width: int | None = None,
|
||||
**rich_kwargs: Any,
|
||||
) -> None:
|
||||
"""
|
||||
|
|
@ -31,6 +32,7 @@ def configure_logging(
|
|||
Args:
|
||||
logger: the logger to configure
|
||||
level: the log level to use
|
||||
console_width: width for Rich console output
|
||||
rich_kwargs: the parameters to use for creating RichHandler
|
||||
"""
|
||||
|
||||
|
|
@ -39,7 +41,7 @@ def configure_logging(
|
|||
|
||||
# Only configure the FastMCP logger namespace
|
||||
handler = RichHandler(
|
||||
console=Console(stderr=True),
|
||||
console=Console(stderr=True, width=console_width),
|
||||
rich_tracebacks=enable_rich_tracebacks,
|
||||
**rich_kwargs,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue