From df0e52cda814b0f25f0e1e1d7cfd31e8fd20607b Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Thu, 25 Jun 2026 23:59:49 +0200 Subject: [PATCH] fix(logs): render plain log notices verbatim instead of mangling them as timestamps A plain message with no timestamp/level (e.g. the Windows 'Syslog is not supported' notice) was parsed by the app-log branch, which took the first three words as date/time/level and dropped the rest. Match the strict 'YYYY/MM/DD LEVEL - body' shape only, keep other lines whole, and drop the leading separator when there is no stamp or level. --- frontend/src/pages/index/LogModal.tsx | 2 +- frontend/src/pages/index/logParse.ts | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/index/LogModal.tsx b/frontend/src/pages/index/LogModal.tsx index ed2b8a76a..0fd27ea63 100644 --- a/frontend/src/pages/index/LogModal.tsx +++ b/frontend/src/pages/index/LogModal.tsx @@ -147,7 +147,7 @@ export default function LogModal({ open, onClose }: LogModalProps) { {log.levelText && {log.levelText}} {(log.body || log.service) && ( <> - - + {(log.stamp || log.levelText) && - } {log.service && {log.service}} {log.service && log.body ? ' ' : ''} {log.body} diff --git a/frontend/src/pages/index/logParse.ts b/frontend/src/pages/index/logParse.ts index 82f595489..23465c920 100644 --- a/frontend/src/pages/index/logParse.ts +++ b/frontend/src/pages/index/logParse.ts @@ -41,6 +41,11 @@ const SYSLOG_PREFIX = /^([A-Za-z]{3}\s+\d{1,2})\s+(\d{2}:\d{2}:\d{2})\s+\S+\s+\S const GO_LOG_DATE = /^\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}\s+/; // telego's own line prefix: "[Mon Jan _2 15:04:05 MST 2006] LEVEL rest". const TELEGO = /^\[[^\]]+\]\s+([A-Z]+)\s+(.*)$/; +// App-log format emitted by the in-memory buffer: +// "2006/01/02 15:04:05 LEVEL - message". Only a line matching this exact shape +// carries a structured timestamp/level; anything else (e.g. a plain notice such +// as the Windows "Syslog is not supported" message) is kept whole as the body. +const APP_LOG = /^(\d{4}\/\d{2}\/\d{2})\s+(\d{2}:\d{2}:\d{2})\s+(\S+)\s+-\s+([\s\S]*)$/; // splitLevelDash pulls a leading "LEVEL - " off a message, returning the level // and the remainder. Returns null when the message does not start with a level. @@ -84,16 +89,17 @@ export function parseLogLine(line: string): ParsedLog { } } } else { - // App-log format: "2006/01/02 15:04:05 LEVEL - body" - const [head, ...rest] = raw.split(' - '); - const message = rest.join(' - '); - const parts = head.split(' '); - if (parts.length >= 3) { - [date, time, levelText] = parts; + const app = raw.match(APP_LOG); + if (app) { + // App-log format: "2006/01/02 15:04:05 LEVEL - body" + date = app[1]; + time = app[2]; + levelText = app[3]; + body = app[4]; } else { - levelText = head; + // Plain message with no timestamp/level — show it verbatim. + body = raw; } - body = message || ''; } const li = LEVELS.indexOf(levelText);