DPP/DLT functionality #36

Merged
pedro merged 68 commits from dpp into main 2024-12-11 15:15:14 +00:00
Showing only changes of commit 09f6cd2e68 - Show all commits

View file

@ -22,8 +22,14 @@ class CustomFormatter(logging.Formatter):
record.levelname = f"{color}{record.levelname}{RESET}" record.levelname = f"{color}{record.levelname}{RESET}"
if record.args: if record.args:
record.msg = self.highlight_args(record.msg, record.args, color) try:
record.args = () record.msg = record.msg % record.args
record.args = ()
except (TypeError, ValueError):
record.msg = f"{color}{record.msg}{RESET}"
# Highlight the final formatted message
record.msg = self.highlight_message(record.msg, color)
# provide trace when DEBUG config # provide trace when DEBUG config
if settings.DEBUG: if settings.DEBUG:
@ -33,8 +39,4 @@ class CustomFormatter(logging.Formatter):
return super().format(record) return super().format(record)
def highlight_args(self, message, args, color): def highlight_args(self, message, args, color):
try: return f"{color}{message}{RESET}"
highlighted_args = tuple(f"{color}{arg}{RESET}" for arg in args)
return message % highlighted_args
except (TypeError, ValueError):
return f"{color}{message}{RESET}"