* Parse one JSON log line produced by the SDK's JsonFormatter and return a * single-line human-readable string + an appropriate ANSI color. * * Returns null for non-JSON lines so callers can fall back to the raw text. * * @param {string} rawLine * @returns {{ text: string; color: string } | nu
(rawLine)
| 163 | * @returns {{ text: string; color: string } | null} |
| 164 | */ |
| 165 | function parseAgentServerLogLine(rawLine) { |
| 166 | try { |
| 167 | const obj = JSON.parse(rawLine); |
| 168 | if (!obj.levelname || obj.message === undefined) return null; |
| 169 | const level = obj.levelname.padEnd(8); |
| 170 | const location = |
| 171 | obj.filename && obj.lineno ? ` ${obj.filename}:${obj.lineno}` : ""; |
| 172 | const text = `${level} ${obj.message}${location}`; |
| 173 | const lvl = obj.levelname; |
| 174 | const color = |
| 175 | lvl === "DEBUG" |
| 176 | ? c.dim |
| 177 | : lvl === "WARNING" |
| 178 | ? c.yellow |
| 179 | : lvl === "ERROR" || lvl === "CRITICAL" |
| 180 | ? c.red |
| 181 | : c.blue; |
| 182 | return { text, color }; |
| 183 | } catch { |
| 184 | return null; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | // ═══════════════════════════════════════════════════════════════════════════ |
| 189 | // Configuration |
nothing calls this directly
no outgoing calls
no test coverage detected