MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / logLevel

Function logLevel

graph-ui/src/system/system-model.ts:25–41  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

23
24/** Only recognize a level token in the prefix, never words inside the message. */
25export function logLevel(line: string): LogLevel {
26 const trimmed = line.trim();
27 let raw: unknown;
28 if (trimmed.startsWith('{')) {
29 try {
30 const record: unknown = JSON.parse(trimmed);
31 if (typeof record === 'object' && record !== null && !Array.isArray(record)) raw = (record as Record<string, unknown>)['level'];
32 } catch { /* A partial JSON line is unclassified. */ }
33 } else {
34 raw = /^level=(\w+)(?=\s|$)/i.exec(trimmed)?.[1]
35 ?? /^(?:(?:\d{4}-\d{2}-\d{2}[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)\s+)?\[?(ERROR|WARN(?:ING)?|INFO|DEBUG|TRACE|FATAL)\]?(?=\s|:|$)/i.exec(trimmed)?.[1];
36 }
37 const token = typeof raw === 'string' ? raw.toLowerCase() : undefined;
38 if (token === 'fatal') return 'error';
39 if (token === 'warning') return 'warn';
40 return token === 'error' || token === 'warn' || token === 'info' || token === 'debug' || token === 'trace' ? token : 'other';
41}
42
43export function filterLogs(lines: readonly string[], query: string, level: LogLevel | 'all'): string[] {
44 const needle = query.trim().toLocaleLowerCase();

Callers 4

DaemonAlertsFunction · 0.90
SystemWorkspaceFunction · 0.90
filterLogsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected