MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / parseLogLine

Function parseLogLine

apps/vis/server/src/lib/log-reader.ts:102–122  ·  view source on GitHub ↗
(raw: string, lineNo: number)

Source from the content-addressed store, hash-verified

100}
101
102export function parseLogLine(raw: string, lineNo: number): LogLine {
103 const m = LINE_RE.exec(raw);
104 if (m === null) {
105 return { lineNo, time: null, level: null, message: raw, fields: {}, raw };
106 }
107 const time = m[1]!;
108 const level = m[2]!.toUpperCase();
109 const rest = m[3]!;
110
111 const fields: Record<string, string> = {};
112 let message = rest;
113 const fieldStart = rest.search(FIELD_START_RE);
114 if (fieldStart >= 0) {
115 message = rest.slice(0, fieldStart).trim();
116 const fieldsPart = rest.slice(fieldStart);
117 for (const fm of fieldsPart.matchAll(FIELD_RE)) {
118 fields[fm[1]!] = fm[2]!;
119 }
120 }
121 return { lineNo, time, level, message: message.trim(), fields, raw };
122}

Callers 2

log-reader.test.tsFile · 0.90
readLogsFunction · 0.85

Calls 2

execMethod · 0.65
searchMethod · 0.65

Tested by

no test coverage detected