mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(logs): a 404 is not written to the app log
Django logs every 4xx as a django.request WARNING; each 404 of a scanner or an old link was a line in the app log, burying the ones that matter. 404s are left out; 403s and errors stay (a refused page also has a Logs row).
This commit is contained in:
parent
a2cc398dce
commit
57f8de9724
3 changed files with 21 additions and 0 deletions
|
|
@ -22,3 +22,11 @@ class RequestFilter(logging.Filter):
|
|||
except Exception: # the user may be read from the database here; a failure must not lose the line
|
||||
pass
|
||||
return True
|
||||
|
||||
|
||||
class NotFoundFilter(logging.Filter):
|
||||
"""Leaves out django.request's line for a 404: scanners and old links
|
||||
would bury the lines that matter."""
|
||||
|
||||
def filter(self, record):
|
||||
return getattr(record, "status_code", None) != 404
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue