configure_uvicorn_logging#

safir.logging.configure_uvicorn_logging(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:

loglevel (str) –

The log level for Uvicorn logs, in string form (case-insensitive):

  • DEBUG

  • INFO

  • WARNINGS

  • ERROR

The default is 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:

None