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

Exception method does not set exc_info #130

Closed
minus7 opened this issue Jun 17, 2017 · 4 comments
Closed

Exception method does not set exc_info #130

minus7 opened this issue Jun 17, 2017 · 4 comments

Comments

@minus7
Copy link

@minus7 minus7 commented Jun 17, 2017

.exception() does not set exc_info=True when used with the default configuration, causing the exception not to be logged. Explicitly adding exc_info=True to the call to exception() does add the info. This seems to have to do with BoundLoggerLazyProxy not having a dedicated exception() proxy that sets exc_info.

Reproduction sample:

import structlog

structlogger = structlog.getLogger(__name__)

try:
    nonexistent()
except:
    structlogger.exception('exception')
@hynek
Copy link
Owner

@hynek hynek commented Jun 19, 2017

exc_info and .exception() are concepts of the standard library. structlog in it’s core is completely agnostic to the underlying logging system. Hence if you want to use stdlib features, you have to configure it as such.

Does that make sense to you?

@minus7
Copy link
Author

@minus7 minus7 commented Jun 19, 2017

I see, but it still doesn't quite make sense; why does .exception() work if it doesn't do what the name advertises. It seems more appropriate to just not have this method available in the first place if it doesn't augment the log message with exception information.

@hynek
Copy link
Owner

@hynek hynek commented Jun 22, 2017

Yes, adding all the stdlib logger names to PrintLogger was probably a bad call in hindsight since – as you point out – it suggests functionality that’s not present at all.

@minus7
Copy link
Author

@minus7 minus7 commented Jun 22, 2017

So it is how it is, and removing the method can't be done without potentially breaking client code. Moving forward and making the method conform to the stdlib logger doesn't make sense either since, as you said, properly configuring structlog with stdlib.BoundLogger fixes the behaviour. Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants