controller¶
Log config for the controllers
Logging config for the application.
Ensures that the app and uvicorn loggers all log through the queue listener.
Adds a filter for health check route logs.
- class byte_bot.server.lib.log.controller.BeforeSendHandler[source]
 Bases:
objectExtraction of request and response data from connection scope.
Configure the handler.
- async __call__(message: Message, scope: Scope) None[source]
 Receives ASGI response messages and scope, and logs per configuration.
- Parameters:
 message – ASGI response event.
scope – ASGI connection scope.
- async log_request(scope: Scope) None[source]
 Handle extracting the request data and logging the message.
- Parameters:
 scope – The ASGI connection scope.
- Returns:
 None
- async log_response(scope: Scope) None[source]
 Handle extracting the response data and logging the message.
- Parameters:
 scope – The ASGI connection scope.
- Returns:
 None
- byte_bot.server.lib.log.controller.drop_health_logs(_: WrappedLogger, __: str, event_dict: EventDict) EventDict[source]
 Prevent logging of successful health checks.
- Parameters:
 _ – Wrapped logger object.
__ – Name of the wrapped method, e.g., “info”, “warning”, etc.
event_dict – Current context with current event, e.g, {“a”: 42, “event”: “foo”}.
- Returns:
 event_dict for further processing if it does not represent a successful health check.
- byte_bot.server.lib.log.controller.middleware_factory(app: ASGIApp) ASGIApp[source]
 Middleware to ensure that every request has a clean structlog context.
- Parameters:
 app – The previous ASGI app in the call chain.
- Returns:
 A new ASGI app that cleans the structlog contextvars.