Ben Sully commited on
Commit
e947e9b
·
unverified ·
1 Parent(s): 18f9037

fix: use stderr for logging

Browse files

Without 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).

Files changed (1) hide show
  1. src/fastmcp/utilities/logging.py +4 -1
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, format="%(message)s", handlers=[RichHandler(rich_tracebacks=True)]
 
 
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
  )