hynek / structlog

Simple, powerful, and fast logging for Python.
https://www.structlog.org/
Other
3.48k stars 220 forks source link

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

Open raqbit opened 2 months ago

raqbit commented 2 months ago

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