1
0
Fork 0
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:
catborise 2026-11-05 18:44:40 +03:00
parent a2cc398dce
commit 57f8de9724
3 changed files with 21 additions and 0 deletions

View file

@ -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