Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Sat, 04 Apr 2020 14:42:24 UTC Commit: fa80c400750d9dbe88131c15324e268a3f21d06b https://github.com/geany/www.geany.org/commit/fa80c400750d9dbe88131c15324e26...
Log Message: ----------- Filter 404 Not Found logs from AdminEmailHandler
There is no point in sending hundreds of 404 logs every day.
Modified Paths: -------------- geany/settings.py
Modified: geany/settings.py 14 lines changed, 13 insertions(+), 1 deletions(-) =================================================================== @@ -464,6 +464,14 @@ ######################### # LOGGING # ######################### +def skip_404_not_found(record): + # filter 404 Not Found log messages and ignore them to prevent sending lots of mails + # via AdminEmailHandler + if record.name == 'django.request' and getattr(record, 'status_code', 0) == 404: + return False + return True + + logging.captureWarnings(True) # log warnings using the logging subsystem LOGGING = { 'version': 1, @@ -485,6 +493,10 @@ 'request_id': { '()': 'log_request_id.filters.RequestIDFilter' }, + 'skip_404_not_found': { + '()': 'django.utils.log.CallbackFilter', + 'callback': skip_404_not_found, + } }, 'handlers': { 'console': { @@ -496,7 +508,7 @@ 'mail_admins': { 'level': 'WARN', 'class': 'django.utils.log.AdminEmailHandler', - 'filters': ['require_debug_false', 'request_id'] + 'filters': ['require_debug_false', 'request_id', 'skip_404_not_found'] }, 'file': { 'level': 'DEBUG',
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).