primus.logging.redaction module

App-side redaction helpers for log messages before external ingestion.

class primus.logging.redaction.RedactingLogFilter(name='')

Bases: Filter

Redact high-risk values before handlers format or ship a record.

Initialize a filter.

Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event.

filter(record: LogRecord) → bool

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

primus.logging.redaction.redact_object(value: Any) → Any
primus.logging.redaction.redact_text(value: str) → str