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

Exceptions aren't logged anymore #226

Closed
ntap-fge opened this issue Apr 12, 2023 · 5 comments · Fixed by #227
Closed

Exceptions aren't logged anymore #226

ntap-fge opened this issue Apr 12, 2023 · 5 comments · Fixed by #227

Comments

@ntap-fge
Copy link

Since version 5.0 RequestMiddleware doesn't log exceptions anymore (tested with Django 3.2, Python 3.9).

The request_failed event seems to have been completely removed and the regular request_finished also doesn't contain the exception.

@jrobichaud
Copy link
Owner

I'll have to investigate, but I am unavailable this week. Please stick to an earlier version in the meantime.

I could not trigger exceptions at all and it appeared to be dead code from an old refactor. I'll have to take a second look.

Just to be sure, you are configured as the documentation and did not create a custom class inheriting from RequestMiddleware?

@ntap-fge
Copy link
Author

Yes, I'm using 'django_structlog.middlewares.RequestMiddleware' as the middleware.

Previously Django called the middleware hook process_exception() which has been removed in 14da9d8

@jrobichaud
Copy link
Owner

jrobichaud commented Apr 16, 2023

The removal was a dumb mistake, I am putting everything back.

However, I have to make sure the middleware is stateless in order to work properly with async. The instance is shared between concurrent requests.

I'll store the _raised_exception flag on the request object instead.

@jrobichaud
Copy link
Owner

@ntap-fge the fix is 5.0.2 that was just released, let me know if you have any problems. Thanks.

@ntap-fge
Copy link
Author

Can confirm that 5.0.2 works fine. Thanks for the quick fix and maintaining django-structlog in general!

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