Module

logging

Logging configuration and access log formatting.

Configures stdlib logging with pounce-specific formatting. Provides both text and JSON access log output for request/response metrics.

Text format:

{timestamp} {level} {client} - "{method} {path} HTTP/{version}" {status} {bytes} {duration}ms

JSON format:

{"timestamp": "...", "level": "INFO", "logger": "pounce.access", "method": "GET", ...}

Classes

_JSONFormatter 1
Structured JSON log formatter for production observability.

Structured JSON log formatter for production observability.

Methods

format 1 str
def format(self, record: logging.LogRecord) -> str
Parameters
Name Type Description
record
Returns
str

Functions

configure_logging 1 None
Configure stdlib logging for pounce and framework loggers. Sets up the pounce …
def configure_logging(config: ServerConfig) -> None

Configure stdlib logging for pounce and framework loggers.

Sets up the pounce logger hierarchy and the chirp framework logger with the configured log level and a stream handler to stderr. Both loggers share the same formatting and output destination.

Whenconfig.log_format is "json", uses structured JSON output.

Parameters
Name Type Description
config ServerConfig

Server configuration with log_level and log_format settings.

access_log 8 None
Log an access log entry for a completed request. When JSON logging is enabled,…
def access_log(method: str, path: str, status: int, bytes_sent: int, duration_ms: float, client: str, *, http_version: str = '1.1', request_id: str | None = None) -> None

Log an access log entry for a completed request.

When JSON logging is enabled, emits a structured JSON object with all fields as top-level keys. Otherwise, uses the standard combined log format.

Parameters
Name Type Description
method str

HTTP method (e.g., "GET").

path str

Request path (e.g., "/api/users").

status int

HTTP response status code.

bytes_sent int

Number of response body bytes sent.

duration_ms float

Request duration in milliseconds.

client str

Client address string (e.g., "127.0.0.1:5000").

http_version str

Protocol version string (e.g., "1.1", "2").

Default:'1.1'
request_id str | None

Optional request ID for tracing.

Default:None