Skip to content
femtologging
Menu

Guides

Format and filter records

Filters accept or enrich records on the producer thread. Callable formatters shape output.

0.2.0 surface · 0.2.0-beta1 forthcoming

Pass a callable formatter

Default text output is {logger} [LEVEL] message. Handler builders accept a callable that takes a record mapping and returns a string. The request-context example produces JSON with the record’s structured metadata.

Formatter identifiers support only "default". FormatterBuilder registration is a placeholder: registering a named formatter does not connect it to an output handler.

Filter before dispatch

LevelFilterBuilder, NameFilterBuilder, and PythonCallbackFilterBuilder configure logger filters. They run in declaration order on the producer thread. A callback may be a callable or a stdlib-style object with filter(record).

A truthy callback accepts the record. Supported new scalar attributes are validated and copied into Rust metadata before enqueueing. Callback cost therefore belongs to the application-side logging path.

Validate enrichment

Do not overwrite stdlib record attributes or femtologging metadata. New fields use non-empty string keys and scalar values. Invalid values, reserved keys, or oversized payloads fail validation rather than silently becoming structured context.

Handler-level filters and levels remain unsupported. See structured record limits and the record/filter reference.