Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
raqbit opened this issue Aug 6, 2024 · 1 comment · Fixed by #677
Closed

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

raqbit opened this issue Aug 6, 2024 · 1 comment · Fixed by #677

Comments

@raqbit
Copy link

raqbit commented Aug 6, 2024

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

hynek added a commit that referenced this issue Nov 15, 2024
@hynek
Copy link
Owner

hynek commented Nov 15, 2024

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

hynek added a commit that referenced this issue Nov 15, 2024
@hynek hynek closed this as completed in 6a111d6 Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants