Skip to content

FilteringBoundLogger fatal method logs with error level instead of critical #640

@raqbit

Description

@raqbit

When using make_filtering_bound_logger, one of the pre-created BoundLoggerFilteringAt<level> instances is used. These instances have the fatal & afatal aliases mapped1 to error & aerror respectively, even though the Python fatal alias is mapped to critical in other loggers (including the Python standard library).

(Side note: After diving into structlog internals to figure out why my fatal logs were not going through the processor chain, I figured out that use of the fatal method is discouraged2)


import structlog, logging
print(structlog.__version__) # 24.4.0
structlog.configure(wrapper_class=structlog.make_filtering_bound_logger(logging.CRITICAL))
structlog.get_logger().critical("something went critically wrong") # [critical ] something went critically wrong
structlog.get_logger().fatal("something went fatally wrong") # Log filtered

Footnotes

  1. https://github.com/hynek/structlog/blob/87ac2babbd193b3836c5d32c9fa81510c28b82e0/src/structlog/_native.py#L205

  2. https://github.com/python/cpython/blob/a8be8fc6c4682089be45a87bd5ee1f686040116c/Lib/logging/__init__.py#L1565

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions