hynek / structlog

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

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

Closed raqbit closed 2 weeks ago

raqbit commented 3 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
hynek commented 2 weeks ago

yeah while working on #670, I noticed fatal is not mentioned in the logging docs at all.

Since people shouldn't be using it and moving it to critical means that the only side effect are potentially more logs, I think this is fine to change. → #677