handle frigate log consolidation

This commit is contained in:
Josh Hawkins 2025-01-15 17:42:47 -06:00
parent 48003179f5
commit 3a203839a9
3 changed files with 21 additions and 9 deletions

View File

@ -480,12 +480,15 @@ def process_logs(
if date_end == 0: if date_end == 0:
date_end = clean_line.index(" ") date_end = clean_line.index(" ")
# for frigate logs attempt to consolidate by comparing
# the first 3 characters of the millisecond portion
key_length = date_end - (6 if service == "frigate" else 0) key_length = date_end - (6 if service == "frigate" else 0)
new_key = clean_line[:key_length] new_key = clean_line[:key_length]
if new_key == current_key: if new_key == current_key:
current_line += f"\n{clean_line[date_end:].strip()}" # use zero-width space character to delineate that this is a continuation
current_line += f"\u200b{clean_line[date_end:].strip()}"
continue continue
else: else:
if current_line: if current_line:

View File

@ -506,7 +506,7 @@ function LogLineData({
return ( return (
<div <div
className={cn( className={cn(
"grid w-full cursor-pointer grid-cols-5 gap-2 border-t border-secondary py-0 hover:bg-muted md:grid-cols-12", "grid w-full cursor-pointer grid-cols-5 gap-2 border-t border-secondary py-2 hover:bg-muted md:grid-cols-12 md:py-0",
className, className,
"*:text-xs", "*:text-xs",
)} )}
@ -530,13 +530,13 @@ function LogLineData({
</div> </div>
<div <div
className={cn( className={cn(
"log-content col-span-5 flex size-full items-center justify-between pr-2", "log-content col-span-5 flex size-full items-center justify-between px-2 md:px-0 md:pr-2",
logService == "frigate" logService == "frigate"
? "md:col-span-7" ? "md:col-span-7 lg:col-span-8"
: "md:col-span-8 lg:col-span-9", : "md:col-span-8 lg:col-span-9",
)} )}
> >
<div className="w-full overflow-hidden text-ellipsis whitespace-nowrap"> <div className="w-full overflow-hidden text-ellipsis">
{line.content} {line.content}
</div> </div>
</div> </div>

View File

@ -24,7 +24,10 @@ export function parseLogLines(logService: LogType, logs: string[]) {
dateStamp: line.substring(0, 19), dateStamp: line.substring(0, 19),
severity: "info", severity: "info",
section: "startup", section: "startup",
content: line.substring(infoIndex + 6).trim(), content: line
.substring(infoIndex + 6)
.trim()
.replace(/\u200b/g, "\n"),
}; };
} }
@ -32,7 +35,10 @@ export function parseLogLines(logService: LogType, logs: string[]) {
dateStamp: line.substring(0, 19), dateStamp: line.substring(0, 19),
severity: "unknown", severity: "unknown",
section: "unknown", section: "unknown",
content: line.substring(30).trim(), content: line
.substring(30)
.trim()
.replace(/\u200b/g, "\n"),
}; };
} }
@ -44,7 +50,7 @@ export function parseLogLines(logService: LogType, logs: string[]) {
return null; return null;
} }
return { const logLine = {
dateStamp: match.toString().slice(1, -1), dateStamp: match.toString().slice(1, -1),
severity: pythonSeverity severity: pythonSeverity
.exec(line) .exec(line)
@ -54,8 +60,11 @@ export function parseLogLines(logService: LogType, logs: string[]) {
section: sectionMatch.toString(), section: sectionMatch.toString(),
content: line content: line
.substring(line.indexOf(":", match.index + match[0].length) + 2) .substring(line.indexOf(":", match.index + match[0].length) + 2)
.trim(), .trim()
.replace(/\u200b/g, "\n"),
}; };
return logLine;
}) })
.filter((value) => value != null) as LogLine[]; .filter((value) => value != null) as LogLine[];
} else if (logService == "go2rtc") { } else if (logService == "go2rtc") {