Skip to content

Instantly share code, notes, and snippets.

@wontonst
Created February 4, 2022 17:31
Show Gist options
  • Save wontonst/275b21522c63a81393fbd53e866abd3a to your computer and use it in GitHub Desktop.
Save wontonst/275b21522c63a81393fbd53e866abd3a to your computer and use it in GitHub Desktop.
request logging middleware
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