configure_uvicorn_logging#
- safir.logging.configure_uvicorn_logging(log_level=LogLevel.INFO)#
Set up logging.
This configures Uvicorn to use structlog for output formatting and installs a custom processor to parse its access log messages into additional log context that matches the format of Google log messages. This helps Google’s Cloud Logging system understand the logs.
- Parameters:
log_level (
LogLevel
, optional) – The Python log level. May be given as aLogLevel
enum (preferred) or a case-insensitive string. The default isLogLevel.INFO
.
Notes
This method should normally be called after
configure_logging
during FastAPI app creation. It should be called during Python module import or inside the function that creates and returns the FastAPI app that Uvicorn will run. This ensures the logging setup is complete before Uvicorn logs its first message.- Return type: