controller
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.
BeforeSendHandler ¶
Extraction of request and response data from connection scope.
__call__
async
¶
Receives ASGI response messages and scope, and logs per configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
Message
|
ASGI response event. |
required |
scope |
Scope
|
ASGI connection scope. |
required |
extract_request_data
async
¶
extract_response_data ¶
log_request
async
¶
Handle extracting the request data and logging the message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope |
Scope
|
The ASGI connection scope. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
log_response
async
¶
Handle extracting the response data and logging the message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope |
Scope
|
The ASGI connection scope. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
drop_health_logs ¶
Prevent logging of successful health checks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_ |
WrappedLogger
|
Wrapped logger object. |
required |
__ |
str
|
Name of the wrapped method, e.g., "info", "warning", etc. |
required |
event_dict |
EventDict
|
Current context with current event, e.g, |
required |
Returns:
Type | Description |
---|---|
EventDict
|
|
middleware_factory ¶
Middleware to ensure that every request has a clean structlog context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app |
ASGIApp
|
The previous ASGI app in the call chain. |
required |
Returns:
Type | Description |
---|---|
ASGIApp
|
A new ASGI app that cleans the structlog contextvars. |