mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-13 11:46:35 +00:00
Ignore VariableDoesNotExist errors in debug logging
They're so noisy as to make debug logging useless otherwise
This commit is contained in:
parent
7905be7de2
commit
7ae0db7f4a
2 changed files with 16 additions and 0 deletions
|
@ -147,6 +147,9 @@ LOGGING = {
|
||||||
"require_debug_true": {
|
"require_debug_true": {
|
||||||
"()": "django.utils.log.RequireDebugTrue",
|
"()": "django.utils.log.RequireDebugTrue",
|
||||||
},
|
},
|
||||||
|
"ignore_missing_variable": {
|
||||||
|
"()": "bookwyrm.utils.log.IgnoreVariableDoesNotExist",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"handlers": {
|
"handlers": {
|
||||||
# Overrides the default handler to make it log to console
|
# Overrides the default handler to make it log to console
|
||||||
|
@ -154,6 +157,7 @@ LOGGING = {
|
||||||
# console if DEBUG=False)
|
# console if DEBUG=False)
|
||||||
"console": {
|
"console": {
|
||||||
"level": LOG_LEVEL,
|
"level": LOG_LEVEL,
|
||||||
|
"filters": ["ignore_missing_variable"],
|
||||||
"class": "logging.StreamHandler",
|
"class": "logging.StreamHandler",
|
||||||
},
|
},
|
||||||
# This is copied as-is from the default logger, and is
|
# This is copied as-is from the default logger, and is
|
||||||
|
|
12
bookwyrm/utils/log.py
Normal file
12
bookwyrm/utils/log.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
class IgnoreVariableDoesNotExist(logging.Filter):
|
||||||
|
def filter(self, record):
|
||||||
|
if(record.exc_info):
|
||||||
|
(errType, errValue, _) = record.exc_info
|
||||||
|
while errValue:
|
||||||
|
if type(errValue).__name__ == 'VariableDoesNotExist':
|
||||||
|
return False
|
||||||
|
errValue = errValue.__context__
|
||||||
|
return True
|
Loading…
Reference in a new issue