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

pytest-structlog catches events with "exception" level while they display "error" level in structlog #30

Closed
b0g3r opened this issue Mar 11, 2024 · 1 comment

Comments

@b0g3r
Copy link
Contributor

b0g3r commented Mar 11, 2024

Latest version of structlog changes behavior of logger.exception a little bit (23.3, 24.1), and now they transform level to "error" in one of the processors, as far as I understand. I would like to see the same behavior in the pytest-structlog, to more accurately test displayable events.

For now pytest-structlog catches level=exception event for logger.exception() calls with stdlib bound logger. I will attach reproducible example in draft PR: #31

b0g3r added a commit to b0g3r/pytest-structlog that referenced this issue Mar 11, 2024
@b0g3r b0g3r mentioned this issue Mar 11, 2024
@wimglenn
Copy link
Owner

wimglenn commented Mar 11, 2024

Thanks for the reproducer - I confirm something changed between structlog 23.2 and 23.3 causing this. It looks like adding

    if method_name == "exception":
        method_name = "error"

into StructuredLogCapture.process would fix this issue, although I'd like to understand better the root cause first.. I had a read through those linked issues and could not quite figure out what went wrong yet.

wimglenn added a commit that referenced this issue Mar 13, 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

No branches or pull requests

2 participants