-
Notifications
You must be signed in to change notification settings - Fork 74
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
Feature/332 fix middleware [2.0] #338
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jamshale
commented
Sep 18, 2023
jamshale
changed the title
Feature/332 fix middleware
Feature/332 fix middleware [2.0] [Do not merge]
Sep 18, 2023
jamshale
force-pushed
the
feature/332-fix-middleware
branch
from
September 19, 2023 17:48
4a896a3
to
1a7b30d
Compare
jamshale
changed the title
Feature/332 fix middleware [2.0] [Do not merge]
Feature/332 fix middleware [2.0]
Sep 19, 2023
jamshale
commented
Sep 19, 2023
jamshale
commented
Sep 19, 2023
jamshale
force-pushed
the
feature/332-fix-middleware
branch
2 times, most recently
from
September 19, 2023 18:09
8176c56
to
e9a0651
Compare
Signed-off-by: jamshale <jamiehalebc@gmail.com>
jamshale
force-pushed
the
feature/332-fix-middleware
branch
from
September 19, 2023 18:11
e9a0651
to
1ce231f
Compare
Signed-off-by: jamshale <jamiehalebc@gmail.com>
Signed-off-by: jamshale <jamiehalebc@gmail.com>
Signed-off-by: jamshale <jamiehalebc@gmail.com>
esune
approved these changes
Sep 19, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the logging middleware function called
call_next
and it experienced an exception then the response object is not available and would throw a response not available in locals exception that would hide the real exception. It is un-catchable in the middleware.This checks if response object exists in the locals in the finally block, and if it does then logs the message, and if it doesn't then it assumes it's an exception and looks in traceback, logs the stack trace and returns a 500 response with a more informative message.
The json logger didn't work with the stacktrace from call_next, which would mean the production stack traces would be invisible. Now this explicitly logs the stacktrace from the middleware if
LOG_WITH_JSON
is True.The stacktrace for the json format (production) is a bit ugly but I can't think of a way to really make them nice so I just log it as one big string.