logging
Logging config for the application.
Ensures that the app, sqlalchemy, saq and uvicorn loggers all log through the queue listener.
Adds a filter for health check route logs.
config
module-attribute
¶
config = LoggingConfig(
root={"level": settings.app.LOG_LEVEL, "handlers": ["queue_listener"]},
filters={"health_filter": {"()": AccessLogFilter, "path_re": f"^{settings.api.HEALTH_PATH}$"}},
formatters={
"standard": {
"format": "%(asctime)s loglevel=%(levelname)-6s logger=%(name)s %(funcName)s() L%(lineno)-4d %(message)s"
}
},
loggers={
"uvicorn.access": {
"propagate": False,
"filters": ["health_filter"],
"handlers": ["queue_listener"],
},
"uvicorn.error": {"propagate": False, "handlers": ["queue_listener"]},
"saq": {"propagate": False, "handlers": ["queue_listener"]},
"sqlalchemy.engine": {"propagate": False, "handlers": ["queue_listener"]},
},
)
Pre-configured log config for application.
AccessLogFilter ¶
Filter for omitting log records from uvicorn access logs based on request path.
Parameters¶
*args : Any
Unpacked into logging.Filter.__init__().
str
Regex, paths matched are filtered.
**kwargs : Any
Unpacked into logging.Filter.__init__().