Skip to content

utils

Logging utilities.

msgspec_json_renderer() A JSON Renderer for structlog using msgspec.

Msgspec doesn't have an API consistent with the stdlib's `json` module,
which is required for structlog's `JSONRenderer`.

EventFilter A structlog processor that removes keys from the log event if they exist.

EventFilter

EventFilter(filter_keys)

Remove keys from the log event.

Add an instance to the processor chain.

Examples structlog.configure( ..., processors=[ ..., EventFilter(["color_message"]), ..., ] )

__call__

__call__(_, __, event_dict)

Receive the log event, and filter keys.

Parameters:

Name Type Description Default
_ required
__ required
event_dict

The data to be logged.

required

Returns:

Type Description
EventDict

The log event with any key in self.filter_keys removed.

msgspec_json_renderer

msgspec_json_renderer(_, __, event_dict)

Structlog processor that uses msgspec for JSON encoding.

Parameters:

Name Type Description Default
_ required
__ required
event_dict

The data to be logged.

required

Returns:

Type Description
bytes

The log event encoded to JSON by msgspec.