Created
February 4, 2022 17:31
-
-
Save wontonst/275b21522c63a81393fbd53e866abd3a to your computer and use it in GitHub Desktop.
request logging middleware
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
class RequestLoggingMiddleware(MiddlewareMixin): | |
def process_response(self, request, response): | |
msg = '{} - {}'.format( | |
request.get_full_path(), | |
response.status_code) | |
if response.status_code > 299 and response.status_code < 400: | |
msg = '{} - {}'.format(msg, response.url) | |
print(msg) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment