Formatter for console logging with colors and prefix.
| 3 | |
| 4 | |
| 5 | class AgentOpsLogFormatter(logging.Formatter): |
| 6 | """Formatter for console logging with colors and prefix.""" |
| 7 | |
| 8 | blue = "\x1b[34m" |
| 9 | bold_red = "\x1b[31;1m" |
| 10 | reset = "\x1b[0m" |
| 11 | prefix = "🖇 AgentOps: " |
| 12 | |
| 13 | FORMATS = { |
| 14 | logging.DEBUG: f"(DEBUG) {prefix}%(message)s", |
| 15 | logging.INFO: f"{prefix}%(message)s", |
| 16 | logging.WARNING: f"{prefix}%(message)s", |
| 17 | logging.ERROR: f"{bold_red}{prefix}%(message)s{reset}", |
| 18 | logging.CRITICAL: f"{bold_red}{prefix}%(message)s{reset}", |
| 19 | } |
| 20 | |
| 21 | def format(self, record): |
| 22 | log_fmt = self.FORMATS.get(record.levelno, self.FORMATS[logging.INFO]) |
| 23 | formatter = logging.Formatter(log_fmt) |
| 24 | return formatter.format(record) |
| 25 | |
| 26 | |
| 27 | class AgentOpsLogFileFormatter(logging.Formatter): |
no outgoing calls
no test coverage detected
searching dependent graphs…