(line: string)
| 46 | |
| 47 | async 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; |
no test coverage detected