MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / log

Function log

examples/policy-advisor/ctf.py:51–64  ·  view source on GitHub ↗

Structured log line with timestamp and colour.

(level: str, msg: str, **kv: object)

Source from the content-addressed store, hash-verified

49
50
51def 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 ----------------------------------------------------------

Callers 4

dry_runFunction · 0.70
run_gateFunction · 0.70
run_gates_concurrentFunction · 0.70
run_ctfFunction · 0.70

Calls 1

getMethod · 0.45

Tested by

no test coverage detected