blackbull.server.access_log¶
blackbull.server.access_log
¶
Per-request access-log helpers shared by the HTTP/1.1 and HTTP/2 paths.
AccessLogRecord
dataclass
¶
Per-request record populated in two phases.
Phase 1 (after parse): client_ip, method, path, http_version. Phase 2 (during send): status, response_bytes. For WebSocket sessions, close_code is captured on disconnect instead. Emitted as one INFO line on 'blackbull.access' after the response completes.
emit_access_log(record)
¶
Emit record on the access logger if INFO is enabled.
The isEnabledFor gate matters: record.format() and
record.as_extra() are evaluated before logger.info decides to
discard the call. Profiling at -R 5000 with BB_ACCESS_LOG=0 showed
these two calls still costing ~1.2% of CPU. Peers (uvicorn / granian /
daphne) skip the work entirely when access logging is disabled; gating
here matches that behaviour.