logger: improve error handling

This commit is contained in:
pedro 2024-11-27 00:38:03 +01:00 committed by Cayo Puigdefabregas
parent 0e0ad400c2
commit d7ff3c2798

View file

@ -33,5 +33,8 @@ class CustomFormatter(logging.Formatter):
return super().format(record)
def highlight_args(self, message, args, color):
try:
highlighted_args = tuple(f"{color}{arg}{RESET}" for arg in args)
return message % highlighted_args
except (TypeError, ValueError):
return f"{color}{message}{RESET}"