structlog icon indicating copy to clipboard operation
structlog copied to clipboard

FilteringBoundLogger fatal method logs with error level instead of critical

Open raqbit opened this issue 1 year ago • 0 comments

When using make_filtering_bound_logger, one of the pre-created BoundLoggerFilteringAt<level> instances is used. These instances have the fatal & afatal aliases mapped^1 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 discouraged^2)


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

raqbit avatar Aug 06 '24 09:08 raqbit