Structured log line with timestamp and colour.
(level: str, msg: str, **kv: object)
| 49 | |
| 50 | |
| 51 | def log(level: str, msg: str, **kv: object) -> None: |
| 52 | """Structured log line with timestamp and colour.""" |
| 53 | ts = datetime.now().strftime("%H:%M:%S.%f")[:-3] |
| 54 | colours = { |
| 55 | "INFO": BLUE, |
| 56 | "GATE": CYAN, |
| 57 | "PASS": GREEN, |
| 58 | "FAIL": RED, |
| 59 | "WARN": YELLOW, |
| 60 | "FLAG": MAGENTA, |
| 61 | } |
| 62 | c = colours.get(level, "") |
| 63 | extra = " ".join(f"{DIM}{k}={v}{RESET}" for k, v in kv.items()) |
| 64 | print(f" {DIM}{ts}{RESET} {c}{level:4}{RESET} {msg} {extra}", flush=True) |
| 65 | |
| 66 | |
| 67 | # -- Gate definitions ---------------------------------------------------------- |
no test coverage detected