MCPcopy Create free account
hub / github.com/LLMQuant/quant-mind / format

Method format

quantmind/utils/logger.py:53–77  ·  view source on GitHub ↗

Format the log record with colors.

(self, record)

Source from the content-addressed store, hash-verified

51 self.use_color = use_color
52
53 def format(self, record):
54 """Format the log record with colors."""
55 if not self.use_color:
56 return super().format(record)
57
58 # Get the base formatted message
59 formatted = super().format(record)
60
61 # Choose color scheme based on level
62 if record.levelname in ["ERROR", "CRITICAL"]:
63 colors = self.BOLD_COLORS
64 else:
65 colors = self.COLORS
66
67 # Apply colors to level name and message
68 color = colors.get(record.levelname, colors["RESET"])
69 reset = colors["RESET"]
70
71 # Color the entire message for errors/critical, just the level for others
72 if record.levelname in ["ERROR", "CRITICAL"]:
73 return f"{color}{formatted}{reset}"
74 else:
75 # Replace the level name with colored version
76 level_colored = f"{color}{record.levelname}{reset}"
77 return formatted.replace(record.levelname, level_colored, 1)
78
79
80def setup_logger(

Callers 2

resolve_magic_inputFunction · 0.80
_compose_instructionsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected