Skip to content
femtologging
Menu

Guides

Create and route loggers

Names, levels, propagation, and handler ownership determine the record path.

0.2.0 surface · 0.2.0-beta1 forthcoming

Name the logger

get_logger(name) returns a registered singleton. Dotted names establish parent relationships: service.api has parent service, which ultimately reaches root. Empty names, leading or trailing dots, and consecutive dots are invalid.

Set the level explicitly when configuring a component. set_propagate(False) isolates a logger whose own handlers provide all output.

Emit a complete message

log(level, message) accepts case-insensitive level names TRACE, DEBUG, INFO, WARN, WARNING, ERROR, and CRITICAL. The debug, info, warning, error, and critical methods take a final message string and optional structured fields.

Build the message before calling the logger. Lazy stdlib formatting with extra positional arguments is unsupported. The return value is the formatted string for an accepted record, or None when filtered; it does not confirm delivery.

Keep output ownership explicit

add_handler and remove_handler change the handlers for subsequent records. Queued records retain their captured handler set, so detaching a handler does not cancel pending work. Stop producers and drain before closing an output.

isEnabledFor checks the effective level. get_dropped() exposes local logger queue drops. reset_manager() is a test utility; it is unsafe as live reconfiguration while other threads use existing loggers.