MCPcopy
hub / github.com/vladmandic/sdnext / addLogLine

Function addLogLine

ui/logMonitor.ts:48–66  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

46
47async function logMonitor() {
48 const addLogLine = (line: string): void => {
49 if (!logMonitorEl) logMonitorEl = document.getElementById('logMonitorData');
50 if (!logMonitorEl) return;
51 try {
52 const l = parseLogLine(line);
53 const row = document.createElement('tr');
54 // row.style = 'padding: 10px; margin: 0;';
55 const level = `<td style="color: var(--color-${l.level.toLowerCase()})">${l.level}</td>`;
56 if (l.level === 'WARNING') logWarnings++;
57 if (l.level === 'ERROR') logErrors++;
58 const module = `<td style="color: var(--neutral-400)">${l.module}</td>`;
59 const facilityText = l.facility.length > 20 ? `${l.facility.substring(0, 20)}...` : l.facility;
60 const facility = l.facility !== 'sd' ? `<td>${facilityText}</td>` : '<td></td>';
61 row.innerHTML = `<td>${dateToStr(l.created)}</td>${level}${facility}${module}<td>${htmlEscape(l.msg)}</td>`;
62 logMonitorEl.appendChild(row);
63 } catch (err) {
64 error(`logMonitor: ${String(err)}\n${line}`);
65 }
66 };
67
68 const cleanupLog = (atBottom: boolean): void => {
69 if (!logMonitorEl) return;

Callers 1

logMonitorFunction · 0.85

Calls 5

errorFunction · 0.90
parseLogLineFunction · 0.85
dateToStrFunction · 0.85
htmlEscapeFunction · 0.85
StringInterface · 0.85

Tested by

no test coverage detected