bookwyrm/bookwyrm/utils/log.py
2022-11-14 01:04:20 -08:00

21 lines
579 B
Python

""" Logging utilities """
import logging
class IgnoreVariableDoesNotExist(logging.Filter):
"""
Filter to ignore VariableDoesNotExist errors
We intentionally pass nonexistent variables to templates a lot, so
these errors are not useful to us.
"""
def filter(self, record):
if record.exc_info:
(_, err_value, _) = record.exc_info
while err_value:
if type(err_value).__name__ == "VariableDoesNotExist":
return False
err_value = err_value.__context__
return True