diff --git a/lib/tfw/logging.py b/lib/tfw/logging.py index 6969000..584f257 100644 --- a/lib/tfw/logging.py +++ b/lib/tfw/logging.py @@ -2,6 +2,7 @@ from datetime import datetime from typing import TextIO, Union from dataclasses import dataclass +from traceback import format_exception from logging import DEBUG, getLogger, Handler, Formatter, Filter @@ -86,10 +87,11 @@ class LogFormatter(Formatter): message = record.msg % clean_args else: message = record.msg + trace = '\n'+''.join(format_exception(*record.exc_info)) if record.exc_info else '' return (f'[{Color.GREY}{date}{Color.RESET}|>' f'{self.severity_to_color[record.levelname]}{record.module}:' - f'{record.levelname.lower()}{Color.RESET}] {message}') + f'{record.levelname.lower()}{Color.RESET}] {message}{trace}') def trim(self, value): if isinstance(value, dict): @@ -107,9 +109,10 @@ class VerboseLogFormatter(Formatter): message = record.msg % record.args else: message = record.msg + trace = '\n'+''.join(format_exception(*record.exc_info)) if record.exc_info else '' return (f'[{date}|>{record.module}:{record.levelname.lower()}] ' - f'{message}') + f'{message}{trace}') class WhitelistFilter(Filter):