|
|
@@ -32,7 +32,9 @@ ColorType = Literal[
|
|
|
|
|
|
LOG_COLORS: Mapping[str, ColorType] = {
|
|
|
'ACTION': 'green',
|
|
|
+ 'USER_ACTION': 'light_red',
|
|
|
'OBSERVATION': 'yellow',
|
|
|
+ 'USER_OBSERVATION': 'light_green',
|
|
|
'DETAIL': 'cyan',
|
|
|
'ERROR': 'red',
|
|
|
'PLAN': 'light_magenta',
|
|
|
@@ -41,7 +43,12 @@ LOG_COLORS: Mapping[str, ColorType] = {
|
|
|
|
|
|
class ColoredFormatter(logging.Formatter):
|
|
|
def format(self, record):
|
|
|
- msg_type = record.__dict__.get('msg_type', None)
|
|
|
+ msg_type = record.__dict__.get('msg_type')
|
|
|
+ event_source = record.__dict__.get('event_source')
|
|
|
+ if event_source:
|
|
|
+ new_msg_type = f'{event_source.upper()}_{msg_type}'
|
|
|
+ if new_msg_type in LOG_COLORS:
|
|
|
+ msg_type = new_msg_type
|
|
|
if msg_type in LOG_COLORS and not DISABLE_COLOR_PRINTING:
|
|
|
msg_type_color = colored(msg_type, LOG_COLORS[msg_type])
|
|
|
msg = colored(record.msg, LOG_COLORS[msg_type])
|
|
|
@@ -50,7 +57,7 @@ class ColoredFormatter(logging.Formatter):
|
|
|
)
|
|
|
name_str = colored(record.name, LOG_COLORS[msg_type])
|
|
|
level_str = colored(record.levelname, LOG_COLORS[msg_type])
|
|
|
- if msg_type in ['ERROR']:
|
|
|
+ if msg_type in ['ERROR'] or config.debug:
|
|
|
return f'{time_str} - {name_str}:{level_str}: {record.filename}:{record.lineno}\n{msg_type_color}\n{msg}'
|
|
|
return f'{time_str} - {msg_type_color}\n{msg}'
|
|
|
elif msg_type == 'STEP':
|