-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Make stdlib.BoundLogger.exception call Logger.exception #572
Make stdlib.BoundLogger.exception call Logger.exception #572
Conversation
005198b
to
02327f8
Compare
@pahrohfit Now the tests are green on the main branch again I've rebased this. I'd be really grateful for a review and any feedback you may have! |
This looks mostly good (although, I once again, regret ever adding stdlib support to structlog as I'm trying to massage away a migraine), but it seems to me that you haven't added a test that ensures that your use-case doesn't break in the future. Would that be feasible? |
Also, fix inconsistent treatment of ProcessorFormatter's keep_exc_info and keep_stack_info args between structlog- and non-structlog-generated LogRecords
ce2c848
to
26c6b27
Compare
Excellent point 🤦 I've added a regression test in my latest commit and rebased this again now. Thanks for looking at this, I'm sorry the stdlib integration causes you pain 😅 I'm extremely grateful for it, it's been so useful to me over the last few months! |
Thank you for the kind words – structlog usually only comes up when people complain about it. 😅 I have added a changelog entry – it would be nice if you could check it for accuracy, because , again, I'm trying to forget as much about this as possible. ;) |
Changelog entry LGTM, thanks for merging! |
Structlog now correctly uses stdlib's `logging.exception` handler when we call `structlog_logger.exception`. Issue: hynek/structlog#571 Fix: hynek/structlog#572
Summary
Closes #571
It does these things:
structlog.stdlib.BoundLogger.exception
proxy to the wrapperLogger
'sexception
method, instead oferror
. This is useful for the niche use case ofHandler
classes that need to deal with both structlog and non-structlog records and prevents such handlers having to reconstructrecord.exc_info
for themselves or rely on structlog processors to do itProcessorFormatter
'skeep_exc_info
andkeep_stack_info
args consistent for log records originating from both structlog and non-structlog loggers.Pull Request Check List
main
branch – use a separate branch!New APIs are added to our typing tests inapi.py
.docs/api.rst
by hand.versionadded
,versionchanged
, ordeprecated
directives..rst
and.md
files is written using semantic newlines.