2023-12-31 14:31:33 +01:00
|
|
|
import { Button } from "@/components/ui/button";
|
2024-03-24 18:23:39 +01:00
|
|
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
2024-04-03 18:55:13 +02:00
|
|
|
import { LogData, LogLine, LogSeverity } from "@/types/log";
|
2023-12-31 14:31:33 +01:00
|
|
|
import copy from "copy-to-clipboard";
|
2024-04-03 18:55:13 +02:00
|
|
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
|
import axios from "axios";
|
2024-04-07 22:36:08 +02:00
|
|
|
import LogInfoDialog from "@/components/overlay/LogInfoDialog";
|
|
|
|
import { LogChip } from "@/components/indicators/Chip";
|
|
|
|
import { LogLevelFilterButton } from "@/components/filter/LogLevelFilter";
|
|
|
|
import { FaCopy } from "react-icons/fa6";
|
|
|
|
import { Toaster } from "@/components/ui/sonner";
|
|
|
|
import { toast } from "sonner";
|
|
|
|
import { isDesktop } from "react-device-detect";
|
2024-04-14 18:14:10 +02:00
|
|
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
2023-12-31 14:31:33 +01:00
|
|
|
|
|
|
|
const logTypes = ["frigate", "go2rtc", "nginx"] as const;
|
|
|
|
type LogType = (typeof logTypes)[number];
|
2023-12-08 14:33:22 +01:00
|
|
|
|
2024-04-03 18:55:13 +02:00
|
|
|
type LogRange = { start: number; end: number };
|
|
|
|
|
|
|
|
const frigateDateStamp = /\[[\d\s-:]*]/;
|
|
|
|
const frigateSeverity = /(DEBUG)|(INFO)|(WARNING)|(ERROR)/;
|
|
|
|
const frigateSection = /[\w.]*/;
|
|
|
|
|
2024-04-07 22:36:08 +02:00
|
|
|
const goSeverity = /(DEB )|(INF )|(WRN )|(ERR )/;
|
2024-04-03 18:55:13 +02:00
|
|
|
const goSection = /\[[\w]*]/;
|
|
|
|
|
|
|
|
const ngSeverity = /(GET)|(POST)|(PUT)|(PATCH)|(DELETE)/;
|
|
|
|
|
2023-12-08 14:33:22 +01:00
|
|
|
function Logs() {
|
2023-12-31 14:31:33 +01:00
|
|
|
const [logService, setLogService] = useState<LogType>("frigate");
|
|
|
|
|
2024-04-12 14:31:30 +02:00
|
|
|
useEffect(() => {
|
2024-04-16 22:55:24 +02:00
|
|
|
document.title = `${logService[0].toUpperCase()}${logService.substring(1)} Logs - Frigate`;
|
2024-04-12 14:31:30 +02:00
|
|
|
}, [logService]);
|
|
|
|
|
2024-04-03 18:55:13 +02:00
|
|
|
// log data handling
|
|
|
|
|
|
|
|
const [logRange, setLogRange] = useState<LogRange>({ start: 0, end: 0 });
|
|
|
|
const [logs, setLogs] = useState<string[]>([]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
axios
|
|
|
|
.get(`logs/${logService}?start=-100`)
|
|
|
|
.then((resp) => {
|
|
|
|
if (resp.status == 200) {
|
|
|
|
const data = resp.data as LogData;
|
|
|
|
setLogRange({
|
|
|
|
start: Math.max(0, data.totalLines - 100),
|
|
|
|
end: data.totalLines,
|
|
|
|
});
|
|
|
|
setLogs(data.lines);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
|
|
|
}, [logService]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (!logs || logs.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const id = setTimeout(() => {
|
|
|
|
axios
|
|
|
|
.get(`logs/${logService}?start=${logRange.end}`)
|
|
|
|
.then((resp) => {
|
|
|
|
if (resp.status == 200) {
|
|
|
|
const data = resp.data as LogData;
|
|
|
|
|
|
|
|
if (data.lines.length > 0) {
|
|
|
|
setLogRange({
|
|
|
|
start: logRange.start,
|
|
|
|
end: data.totalLines,
|
|
|
|
});
|
|
|
|
setLogs([...logs, ...data.lines]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
|
|
|
}, 5000);
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
if (id) {
|
|
|
|
clearTimeout(id);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}, [logs, logService, logRange]);
|
|
|
|
|
|
|
|
// convert to log data
|
|
|
|
|
|
|
|
const logLines = useMemo<LogLine[]>(() => {
|
|
|
|
if (!logs) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2023-12-31 14:31:33 +01:00
|
|
|
if (logService == "frigate") {
|
2024-04-03 18:55:13 +02:00
|
|
|
return logs
|
|
|
|
.map((line) => {
|
|
|
|
const match = frigateDateStamp.exec(line);
|
|
|
|
|
|
|
|
if (!match) {
|
|
|
|
const infoIndex = line.indexOf("[INFO]");
|
|
|
|
|
|
|
|
if (infoIndex != -1) {
|
|
|
|
return {
|
|
|
|
dateStamp: line.substring(0, 19),
|
|
|
|
severity: "info",
|
|
|
|
section: "startup",
|
|
|
|
content: line.substring(infoIndex + 6).trim(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-04-09 15:53:21 +02:00
|
|
|
return {
|
|
|
|
dateStamp: line.substring(0, 19),
|
|
|
|
severity: "unknown",
|
|
|
|
section: "unknown",
|
|
|
|
content: line.substring(30).trim(),
|
|
|
|
};
|
2024-04-03 18:55:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const sectionMatch = frigateSection.exec(
|
|
|
|
line.substring(match.index + match[0].length).trim(),
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!sectionMatch) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
dateStamp: match.toString().slice(1, -1),
|
|
|
|
severity: frigateSeverity
|
|
|
|
.exec(line)
|
|
|
|
?.at(0)
|
|
|
|
?.toString()
|
|
|
|
?.toLowerCase() as LogSeverity,
|
|
|
|
section: sectionMatch.toString(),
|
|
|
|
content: line
|
|
|
|
.substring(line.indexOf(":", match.index + match[0].length) + 2)
|
|
|
|
.trim(),
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.filter((value) => value != null) as LogLine[];
|
2023-12-31 14:31:33 +01:00
|
|
|
} else if (logService == "go2rtc") {
|
2024-04-03 18:55:13 +02:00
|
|
|
return logs
|
|
|
|
.map((line) => {
|
|
|
|
if (line.length == 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const severity = goSeverity.exec(line);
|
|
|
|
|
|
|
|
let section =
|
|
|
|
goSection.exec(line)?.toString()?.slice(1, -1) ?? "startup";
|
|
|
|
|
|
|
|
if (frigateSeverity.exec(section)) {
|
|
|
|
section = "startup";
|
|
|
|
}
|
|
|
|
|
|
|
|
let contentStart;
|
|
|
|
|
|
|
|
if (section == "startup") {
|
|
|
|
if (severity) {
|
|
|
|
contentStart = severity.index + severity[0].length;
|
|
|
|
} else {
|
|
|
|
contentStart = line.lastIndexOf("]") + 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
contentStart = line.indexOf(section) + section.length + 2;
|
|
|
|
}
|
|
|
|
|
2024-04-07 22:36:08 +02:00
|
|
|
let severityCat: LogSeverity;
|
|
|
|
switch (severity?.at(0)?.toString().trim()) {
|
|
|
|
case "INF":
|
|
|
|
severityCat = "info";
|
|
|
|
break;
|
|
|
|
case "WRN":
|
|
|
|
severityCat = "warning";
|
|
|
|
break;
|
|
|
|
case "ERR":
|
|
|
|
severityCat = "error";
|
|
|
|
break;
|
|
|
|
case "DBG":
|
|
|
|
case "TRC":
|
|
|
|
severityCat = "debug";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
severityCat = "info";
|
|
|
|
}
|
|
|
|
|
2024-04-03 18:55:13 +02:00
|
|
|
return {
|
|
|
|
dateStamp: line.substring(0, 19),
|
2024-04-07 22:36:08 +02:00
|
|
|
severity: severityCat,
|
2024-04-03 18:55:13 +02:00
|
|
|
section: section,
|
|
|
|
content: line.substring(contentStart).trim(),
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.filter((value) => value != null) as LogLine[];
|
2023-12-31 14:31:33 +01:00
|
|
|
} else if (logService == "nginx") {
|
2024-04-03 18:55:13 +02:00
|
|
|
return logs
|
|
|
|
.map((line) => {
|
|
|
|
if (line.length == 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
dateStamp: line.substring(0, 19),
|
2024-04-07 22:36:08 +02:00
|
|
|
severity: "info",
|
2024-04-03 18:55:13 +02:00
|
|
|
section: ngSeverity.exec(line)?.at(0)?.toString() ?? "META",
|
|
|
|
content: line.substring(line.indexOf(" ", 20)).trim(),
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.filter((value) => value != null) as LogLine[];
|
2023-12-31 14:31:33 +01:00
|
|
|
} else {
|
2024-04-03 18:55:13 +02:00
|
|
|
return [];
|
2023-12-31 14:31:33 +01:00
|
|
|
}
|
2024-04-03 18:55:13 +02:00
|
|
|
}, [logs, logService]);
|
2023-12-31 14:31:33 +01:00
|
|
|
|
|
|
|
const handleCopyLogs = useCallback(() => {
|
2024-04-03 18:55:13 +02:00
|
|
|
if (logs) {
|
|
|
|
copy(logs.join("\n"));
|
2024-04-07 22:36:08 +02:00
|
|
|
toast.success(
|
|
|
|
logRange.start == 0
|
|
|
|
? "Coplied logs to clipboard"
|
|
|
|
: "Copied visible logs to clipboard",
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
toast.error("Could not copy logs to clipboard");
|
2024-04-03 18:55:13 +02:00
|
|
|
}
|
2024-04-07 22:36:08 +02:00
|
|
|
}, [logs, logRange]);
|
2023-12-31 14:31:33 +01:00
|
|
|
|
2024-04-03 18:55:13 +02:00
|
|
|
// scroll to bottom
|
|
|
|
|
|
|
|
const [initialScroll, setInitialScroll] = useState(false);
|
2024-02-24 01:25:00 +01:00
|
|
|
|
|
|
|
const contentRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
const [endVisible, setEndVisible] = useState(true);
|
2024-04-03 18:55:13 +02:00
|
|
|
const endObserver = useRef<IntersectionObserver | null>(null);
|
2024-02-24 01:25:00 +01:00
|
|
|
const endLogRef = useCallback(
|
|
|
|
(node: HTMLElement | null) => {
|
2024-04-03 18:55:13 +02:00
|
|
|
if (endObserver.current) endObserver.current.disconnect();
|
2024-02-24 01:25:00 +01:00
|
|
|
try {
|
2024-04-03 18:55:13 +02:00
|
|
|
endObserver.current = new IntersectionObserver((entries) => {
|
2024-02-24 01:25:00 +01:00
|
|
|
setEndVisible(entries[0].isIntersecting);
|
|
|
|
});
|
2024-04-03 18:55:13 +02:00
|
|
|
if (node) endObserver.current.observe(node);
|
2024-02-24 01:25:00 +01:00
|
|
|
} catch (e) {
|
|
|
|
// no op
|
|
|
|
}
|
|
|
|
},
|
2024-02-28 23:23:56 +01:00
|
|
|
[setEndVisible],
|
2024-02-24 01:25:00 +01:00
|
|
|
);
|
2024-04-03 18:55:13 +02:00
|
|
|
const startObserver = useRef<IntersectionObserver | null>(null);
|
|
|
|
const startLogRef = useCallback(
|
|
|
|
(node: HTMLElement | null) => {
|
|
|
|
if (startObserver.current) startObserver.current.disconnect();
|
|
|
|
|
|
|
|
if (logs.length == 0 || !initialScroll) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
startObserver.current = new IntersectionObserver((entries) => {
|
|
|
|
if (entries[0].isIntersecting && logRange.start > 0) {
|
|
|
|
const start = Math.max(0, logRange.start - 100);
|
|
|
|
|
|
|
|
axios
|
|
|
|
.get(`logs/${logService}?start=${start}&end=${logRange.start}`)
|
|
|
|
.then((resp) => {
|
|
|
|
if (resp.status == 200) {
|
|
|
|
const data = resp.data as LogData;
|
|
|
|
|
|
|
|
if (data.lines.length > 0) {
|
|
|
|
setLogRange({
|
|
|
|
start: start,
|
|
|
|
end: logRange.end,
|
|
|
|
});
|
|
|
|
setLogs([...data.lines, ...logs]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
2024-04-14 22:43:43 +02:00
|
|
|
contentRef.current?.scrollBy({
|
|
|
|
top: 10,
|
|
|
|
});
|
2024-04-03 18:55:13 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (node) startObserver.current.observe(node);
|
|
|
|
} catch (e) {
|
|
|
|
// no op
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// we need to listen on the current range of visible items
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
[logRange, initialScroll],
|
|
|
|
);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (logLines.length == 0) {
|
|
|
|
setInitialScroll(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (initialScroll) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!contentRef.current) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (contentRef.current.scrollHeight <= contentRef.current.clientHeight) {
|
|
|
|
setInitialScroll(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
contentRef.current?.scrollTo({
|
|
|
|
top: contentRef.current?.scrollHeight,
|
|
|
|
behavior: "instant",
|
|
|
|
});
|
|
|
|
setTimeout(() => setInitialScroll(true), 300);
|
|
|
|
// we need to listen on the current range of visible items
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [logLines, logService]);
|
2024-02-24 01:25:00 +01:00
|
|
|
|
2024-04-07 22:36:08 +02:00
|
|
|
// log filtering
|
|
|
|
|
|
|
|
const [filterSeverity, setFilterSeverity] = useState<LogSeverity[]>();
|
|
|
|
|
|
|
|
// log selection
|
|
|
|
|
|
|
|
const [selectedLog, setSelectedLog] = useState<LogLine>();
|
|
|
|
|
2023-12-08 14:33:22 +01:00
|
|
|
return (
|
2024-03-30 19:44:12 +01:00
|
|
|
<div className="size-full p-2 flex flex-col">
|
2024-04-07 22:36:08 +02:00
|
|
|
<Toaster position="top-center" />
|
|
|
|
<LogInfoDialog logLine={selectedLog} setLogLine={setSelectedLog} />
|
|
|
|
|
2023-12-31 14:31:33 +01:00
|
|
|
<div className="flex justify-between items-center">
|
2024-03-24 18:23:39 +01:00
|
|
|
<ToggleGroup
|
2024-04-04 05:22:11 +02:00
|
|
|
className="*:px-3 *:py-4 *:rounded-md"
|
2024-03-24 18:23:39 +01:00
|
|
|
type="single"
|
|
|
|
size="sm"
|
|
|
|
value={logService}
|
2024-04-03 18:55:13 +02:00
|
|
|
onValueChange={(value: LogType) => {
|
|
|
|
if (value) {
|
|
|
|
setLogs([]);
|
2024-04-07 22:36:08 +02:00
|
|
|
setFilterSeverity(undefined);
|
2024-04-03 18:55:13 +02:00
|
|
|
setLogService(value);
|
|
|
|
}
|
|
|
|
}} // don't allow the severity to be unselected
|
2024-03-24 18:23:39 +01:00
|
|
|
>
|
|
|
|
{Object.values(logTypes).map((item) => (
|
|
|
|
<ToggleGroupItem
|
|
|
|
key={item}
|
2024-04-19 19:17:23 +02:00
|
|
|
className={`flex items-center justify-between gap-2 ${logService == item ? "" : "text-muted-foreground"}`}
|
2024-03-24 18:23:39 +01:00
|
|
|
value={item}
|
|
|
|
aria-label={`Select ${item}`}
|
|
|
|
>
|
2024-04-07 22:36:08 +02:00
|
|
|
<div className="capitalize">{item}</div>
|
2024-03-24 18:23:39 +01:00
|
|
|
</ToggleGroupItem>
|
|
|
|
))}
|
|
|
|
</ToggleGroup>
|
2024-04-07 22:36:08 +02:00
|
|
|
<div className="flex items-center gap-2">
|
2024-03-24 18:23:39 +01:00
|
|
|
<Button
|
|
|
|
className="flex justify-between items-center gap-2"
|
|
|
|
size="sm"
|
|
|
|
onClick={handleCopyLogs}
|
|
|
|
>
|
2024-04-16 22:55:24 +02:00
|
|
|
<FaCopy className="text-secondary-foreground" />
|
2024-04-10 00:49:14 +02:00
|
|
|
<div className="hidden md:block text-primary">
|
2024-04-07 22:36:08 +02:00
|
|
|
Copy to Clipboard
|
|
|
|
</div>
|
2024-03-24 18:23:39 +01:00
|
|
|
</Button>
|
2024-04-07 22:36:08 +02:00
|
|
|
<LogLevelFilterButton
|
|
|
|
selectedLabels={filterSeverity}
|
|
|
|
updateLabelFilter={setFilterSeverity}
|
|
|
|
/>
|
2023-12-31 14:31:33 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-04-03 18:55:13 +02:00
|
|
|
{initialScroll && !endVisible && (
|
2024-02-28 15:16:32 +01:00
|
|
|
<Button
|
2024-04-10 00:49:14 +02:00
|
|
|
className="absolute bottom-8 left-[50%] -translate-x-[50%] rounded-md text-primary bg-secondary-foreground z-20 p-2"
|
2024-02-24 01:25:00 +01:00
|
|
|
onClick={() =>
|
|
|
|
contentRef.current?.scrollTo({
|
|
|
|
top: contentRef.current?.scrollHeight,
|
|
|
|
behavior: "smooth",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
>
|
|
|
|
Jump to Bottom
|
2024-02-28 15:16:32 +01:00
|
|
|
</Button>
|
2024-02-24 01:25:00 +01:00
|
|
|
)}
|
|
|
|
|
2024-04-14 18:14:10 +02:00
|
|
|
<div className="relative size-full flex flex-col my-2 font-mono text-sm sm:p-2 whitespace-pre-wrap bg-background_alt border border-secondary rounded-md overflow-hidden">
|
2024-04-10 00:49:14 +02:00
|
|
|
<div className="grid grid-cols-5 sm:grid-cols-8 md:grid-cols-12 *:px-2 *:py-3 *:text-sm *:text-primary/40">
|
2024-04-07 22:36:08 +02:00
|
|
|
<div className="p-1 flex items-center capitalize">Type</div>
|
|
|
|
<div className="col-span-2 sm:col-span-1 flex items-center">
|
2024-04-03 18:55:13 +02:00
|
|
|
Timestamp
|
|
|
|
</div>
|
2024-04-07 22:36:08 +02:00
|
|
|
<div className="col-span-2 flex items-center">Tag</div>
|
|
|
|
<div className="col-span-5 sm:col-span-4 md:col-span-8 flex items-center">
|
2024-04-03 18:55:13 +02:00
|
|
|
Message
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-07 22:36:08 +02:00
|
|
|
<div
|
|
|
|
ref={contentRef}
|
|
|
|
className="w-full flex flex-col overflow-y-auto no-scrollbar"
|
|
|
|
>
|
|
|
|
{logLines.length > 0 &&
|
|
|
|
[...Array(logRange.end).keys()].map((idx) => {
|
|
|
|
const logLine =
|
|
|
|
idx >= logRange.start
|
|
|
|
? logLines[idx - logRange.start]
|
|
|
|
: undefined;
|
|
|
|
|
|
|
|
if (logLine) {
|
|
|
|
const line = logLines[idx - logRange.start];
|
|
|
|
if (filterSeverity && !filterSeverity.includes(line.severity)) {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
ref={idx == logRange.start + 10 ? startLogRef : undefined}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<LogLineData
|
|
|
|
key={`${idx}-${logService}`}
|
|
|
|
startRef={
|
|
|
|
idx == logRange.start + 10 ? startLogRef : undefined
|
|
|
|
}
|
|
|
|
className={initialScroll ? "" : "invisible"}
|
|
|
|
line={line}
|
|
|
|
onClickSeverity={() => setFilterSeverity([line.severity])}
|
|
|
|
onSelect={() => setSelectedLog(line)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-04-03 18:55:13 +02:00
|
|
|
return (
|
2024-04-07 22:36:08 +02:00
|
|
|
<div
|
2024-04-03 18:55:13 +02:00
|
|
|
key={`${idx}-${logService}`}
|
2024-04-07 22:36:08 +02:00
|
|
|
className={isDesktop ? "h-12" : "h-16"}
|
2024-04-03 18:55:13 +02:00
|
|
|
/>
|
|
|
|
);
|
2024-04-07 22:36:08 +02:00
|
|
|
})}
|
|
|
|
{logLines.length > 0 && <div id="page-bottom" ref={endLogRef} />}
|
|
|
|
</div>
|
2024-04-14 18:14:10 +02:00
|
|
|
{logLines.length == 0 && (
|
|
|
|
<ActivityIndicator className="absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2" />
|
|
|
|
)}
|
2024-04-03 18:55:13 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
type LogLineDataProps = {
|
|
|
|
startRef?: (node: HTMLDivElement | null) => void;
|
|
|
|
className: string;
|
|
|
|
line: LogLine;
|
2024-04-07 22:36:08 +02:00
|
|
|
onClickSeverity: () => void;
|
|
|
|
onSelect: () => void;
|
2024-04-03 18:55:13 +02:00
|
|
|
};
|
2024-04-07 22:36:08 +02:00
|
|
|
function LogLineData({
|
|
|
|
startRef,
|
|
|
|
className,
|
|
|
|
line,
|
|
|
|
onClickSeverity,
|
|
|
|
onSelect,
|
|
|
|
}: LogLineDataProps) {
|
2024-04-03 18:55:13 +02:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
ref={startRef}
|
2024-04-07 22:36:08 +02:00
|
|
|
className={`w-full py-2 grid grid-cols-5 sm:grid-cols-8 md:grid-cols-12 gap-2 border-secondary border-t cursor-pointer hover:bg-muted ${className} *:text-sm`}
|
|
|
|
onClick={onSelect}
|
2024-04-03 18:55:13 +02:00
|
|
|
>
|
2024-04-07 22:36:08 +02:00
|
|
|
<div className="h-full p-1 flex items-center gap-2">
|
|
|
|
<LogChip severity={line.severity} onClickSeverity={onClickSeverity} />
|
2024-04-03 18:55:13 +02:00
|
|
|
</div>
|
|
|
|
<div className="h-full col-span-2 sm:col-span-1 flex items-center">
|
|
|
|
{line.dateStamp}
|
|
|
|
</div>
|
2024-04-07 22:36:08 +02:00
|
|
|
<div className="size-full pr-2 col-span-2 flex items-center">
|
|
|
|
<div className="w-full overflow-hidden whitespace-nowrap text-ellipsis">
|
|
|
|
{line.section}
|
|
|
|
</div>
|
2024-04-03 18:55:13 +02:00
|
|
|
</div>
|
2024-04-07 22:36:08 +02:00
|
|
|
<div className="size-full pl-2 sm:pl-0 pr-2 col-span-5 sm:col-span-4 md:col-span-8 flex justify-between items-center">
|
|
|
|
<div className="w-full overflow-hidden whitespace-nowrap text-ellipsis">
|
2024-04-03 18:55:13 +02:00
|
|
|
{line.content}
|
|
|
|
</div>
|
2023-12-31 14:31:33 +01:00
|
|
|
</div>
|
2024-02-21 21:07:32 +01:00
|
|
|
</div>
|
2023-12-08 14:33:22 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Logs;
|