mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 22:11:57 +00:00
Print stack trace during an exception
This commit is contained in:
parent
3be018eb17
commit
882ab60490
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user