handle frigate log consolidation

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

View File

@ -418,12 +418,15 @@ def process_logs(
if date_end == 0:
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)
new_key = clean_line[:key_length]
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
else:
if current_line:

View File

@ -506,7 +506,7 @@ function LogLineData({
return (
<div
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,
"*:text-xs",
)}
@ -530,13 +530,13 @@ function LogLineData({
</div>
<div
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"
? "md:col-span-7"
? "md:col-span-7 lg:col-span-8"
: "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}
</div>
</div>

View File

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