mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 07:21:32 +00:00
Improve color scheme
This commit is contained in:
parent
dc62508a7b
commit
f6a369496d
@ -7,14 +7,13 @@ from logging import DEBUG, getLogger, Handler, Formatter, Filter
|
||||
|
||||
|
||||
class Color:
|
||||
GREY = '\033[30;1m'
|
||||
RED = '\033[31m'
|
||||
BOLDRED = '\033[31;1m'
|
||||
BOLDGREEN = '\033[32;1m'
|
||||
YELLOW = '\033[33;1m'
|
||||
CYAN = '\033[36m'
|
||||
BOLDWHITE = '\033[37;1m'
|
||||
RESET = '\033[0m'
|
||||
RED = '\033[31m'
|
||||
GREEN = '\033[32m'
|
||||
YELLOW = '\033[33m'
|
||||
BLUE = '\033[34m'
|
||||
CYAN = '\033[36m'
|
||||
WHITE = '\033[37m'
|
||||
RESET = '\033[0m'
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -67,11 +66,11 @@ class LogHandler(Handler):
|
||||
|
||||
class LogFormatter(Formatter):
|
||||
severity_to_color = {
|
||||
'CRITICAL' : Color.BOLDRED,
|
||||
'CRITICAL' : Color.RED,
|
||||
'ERROR' : Color.RED,
|
||||
'WARNING' : Color.YELLOW,
|
||||
'INFO' : Color.BOLDGREEN,
|
||||
'DEBUG' : Color.BOLDWHITE,
|
||||
'INFO' : Color.GREEN,
|
||||
'DEBUG' : Color.BLUE,
|
||||
'NOTSET' : Color.CYAN
|
||||
}
|
||||
|
||||
@ -80,7 +79,7 @@ class LogFormatter(Formatter):
|
||||
super().__init__()
|
||||
|
||||
def format(self, record):
|
||||
date = datetime.utcfromtimestamp(record.created).strftime('%H:%M:%S')
|
||||
time = datetime.utcfromtimestamp(record.created).strftime('%H:%M:%S')
|
||||
if record.args:
|
||||
tuple_args = (record.args,) if isinstance(record.args, dict) else record.args
|
||||
clean_args = tuple((self.trim(arg) for arg in tuple_args))
|
||||
@ -89,7 +88,7 @@ class LogFormatter(Formatter):
|
||||
message = record.msg
|
||||
trace = '\n'+''.join(format_exception(*record.exc_info)) if record.exc_info else ''
|
||||
|
||||
return (f'[{Color.GREY}{date}{Color.RESET}|>'
|
||||
return (f'[{Color.WHITE}{time}{Color.RESET}|>'
|
||||
f'{self.severity_to_color[record.levelname]}{record.module}:'
|
||||
f'{record.levelname.lower()}{Color.RESET}] {message}{trace}')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user