Spaces:
Running
Running
Ben Sully commited on
fix: use stderr for logging
Browse filesWithout this, logs get sent to stdout which is captured by the
JSONRPC protocol (which also causes some errors with clients when
the invalid JSON is sent over the stdout pipe).
src/fastmcp/utilities/logging.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
import logging
|
| 4 |
from typing import Literal
|
| 5 |
|
|
|
|
| 6 |
from rich.logging import RichHandler
|
| 7 |
|
| 8 |
|
|
@@ -27,5 +28,7 @@ def configure_logging(
|
|
| 27 |
level: the log level to use
|
| 28 |
"""
|
| 29 |
logging.basicConfig(
|
| 30 |
-
level=level,
|
|
|
|
|
|
|
| 31 |
)
|
|
|
|
| 3 |
import logging
|
| 4 |
from typing import Literal
|
| 5 |
|
| 6 |
+
from rich.console import Console
|
| 7 |
from rich.logging import RichHandler
|
| 8 |
|
| 9 |
|
|
|
|
| 28 |
level: the log level to use
|
| 29 |
"""
|
| 30 |
logging.basicConfig(
|
| 31 |
+
level=level,
|
| 32 |
+
format="%(message)s",
|
| 33 |
+
handlers=[RichHandler(console=Console(stderr=True), rich_tracebacks=True)],
|
| 34 |
)
|