(self, record: logging.LogRecord)
| 148 | return f"{DIM}[{RESET}{color}{label}{RESET}{DIM}]{RESET}" |
| 149 | |
| 150 | def format(self, record: logging.LogRecord) -> str: |
| 151 | # Pre-render message (honors %-args and {}-args). |
| 152 | try: |
| 153 | message = record.getMessage() |
| 154 | except Exception: |
| 155 | message = record.msg |
| 156 | |
| 157 | highlight_exec_usage = ( |
| 158 | record.name == "Fronter" |
| 159 | and isinstance(message, str) |
| 160 | and message.startswith(EXEC_USAGE_PREFIX) |
| 161 | ) |
| 162 | highlight_ca_download = ( |
| 163 | isinstance(message, str) |
| 164 | and message.startswith(CA_DOWNLOAD_PREFIX) |
| 165 | ) |
| 166 | |
| 167 | if highlight_ca_download: |
| 168 | plain_time = self._fmt_time(record) |
| 169 | plain_level = f"{LEVEL_GLYPH.get(record.levelname, '·')} {LEVEL_LABEL.get(record.levelname, record.levelname[:5].ljust(5))}" |
| 170 | plain_comp = f"[{record.name[: self.COMPONENT_WIDTH].ljust(self.COMPONENT_WIDTH)}]" |
| 171 | line = f"{plain_time} {plain_level} {plain_comp} {message}" |
| 172 | if self.use_color: |
| 173 | line = f"{BOLD}{FG_GREEN}{line}{RESET}" |
| 174 | elif highlight_exec_usage: |
| 175 | # Force a single vivid color for the entire line so this metric pops. |
| 176 | plain_time = self._fmt_time(record) |
| 177 | plain_level = f"{LEVEL_GLYPH.get(record.levelname, '·')} {LEVEL_LABEL.get(record.levelname, record.levelname[:5].ljust(5))}" |
| 178 | plain_comp = f"[{record.name[: self.COMPONENT_WIDTH].ljust(self.COMPONENT_WIDTH)}]" |
| 179 | line = f"{plain_time} {plain_level} {plain_comp} {message}" |
| 180 | if self.use_color: |
| 181 | line = f"{BOLD}{FG_CYAN}{line}{RESET}" |
| 182 | else: |
| 183 | time_part = self._fmt_time(record) |
| 184 | level_part = self._fmt_level(record.levelname) |
| 185 | comp_part = self._fmt_component(record.name) |
| 186 | |
| 187 | if self.use_color: |
| 188 | time_part = f"{DIM}{FG_GRAY}{time_part}{RESET}" |
| 189 | |
| 190 | line = f"{time_part} {level_part} {comp_part} {message}" |
| 191 | |
| 192 | # Exception tracebacks: render dimmed below the main line. |
| 193 | if record.exc_info: |
| 194 | tb = self.formatException(record.exc_info) |
| 195 | if self.use_color: |
| 196 | tb = f"{DIM}{FG_GRAY}{tb}{RESET}" |
| 197 | line = f"{line}\n{tb}" |
| 198 | if record.stack_info: |
| 199 | si = record.stack_info |
| 200 | if self.use_color: |
| 201 | si = f"{DIM}{FG_GRAY}{si}{RESET}" |
| 202 | line = f"{line}\n{si}" |
| 203 | |
| 204 | return line |
| 205 | |
| 206 | |
| 207 | # ─── public API ──────────────────────────────────────────────────────────── |
nothing calls this directly
no test coverage detected