core/logging: no need for super call in Filter

This commit is contained in:
karlicoss 2023-10-12 22:29:14 +01:00
parent 68289c1be3
commit bb478f369d

View file

@ -165,16 +165,13 @@ def _setup_handlers_and_formatters(name: str) -> None:
# todo also amend by post about defensive error handling? # todo also amend by post about defensive error handling?
class AddExceptionTraceback(logging.Filter): class AddExceptionTraceback(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool: def filter(self, record: logging.LogRecord) -> bool:
s = super().filter(record)
if s is False:
return False
if record.levelname == 'ERROR': if record.levelname == 'ERROR':
exc = record.msg exc = record.msg
if isinstance(exc, BaseException): if isinstance(exc, BaseException):
if record.exc_info is None or record.exc_info == (None, None, None): if record.exc_info is None or record.exc_info == (None, None, None):
exc_info = (type(exc), exc, exc.__traceback__) exc_info = (type(exc), exc, exc.__traceback__)
record.exc_info = exc_info record.exc_info = exc_info
return s return True
# todo also save full log in a file? # todo also save full log in a file?