From b7ba8d6e8e6d9f33ed357e72693ea93aeb2f25c5 Mon Sep 17 00:00:00 2001 From: benStre Date: Sun, 11 Feb 2024 10:58:51 +0100 Subject: [PATCH] improve debug logs --- src/app/debugging/logs.tsx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/debugging/logs.tsx b/src/app/debugging/logs.tsx index 14d2161cd..f28d88de0 100644 --- a/src/app/debugging/logs.tsx +++ b/src/app/debugging/logs.tsx @@ -5,6 +5,7 @@ import { unsafeHTML } from "../../html/unsafe-html.ts"; const messageLoggerEnabled = $$(false); const verboseLogsEnabled = $$(false); +const logFilter = $$(""); const logsContainer =
const component =
@@ -17,6 +18,7 @@ const component =
Enable Verbose Logs +
@@ -36,6 +38,22 @@ effect(() => { else DebugLogs.disableVerboseLogs.to(app.backend!)(); }); +function filterLogs() { + if (!logFilter.val) { + logsContainer.childNodes.forEach((el: HTMLElement) => el.style.display = "flex"); + return; + }; + + for (const child of logsContainer.children) { + if (child instanceof HTMLElement) { + if ((child.lastChild as Element).innerText?.toLowerCase().includes(logFilter.val.toLowerCase())) { + child.style.display = "flex"; + } + else child.style.display = "none"; + } + } +} + (document as any).body.appendChild(component); (document as any).body.style.margin = "0"; @@ -46,10 +64,14 @@ const reader = stream.getReader(); while (true) { const val = await reader.read(); - const child = + const child = {new Date().toLocaleTimeString()} {unsafeHTML(convertANSIToHTML(val.value as string))} ; + + // filter logs + if (logFilter.val && !(child.lastChild as Element).innerText?.toLowerCase().includes(logFilter.val.toLowerCase())) child.style.display = "none"; + const scrollDown = Math.abs(logsContainer.scrollHeight - logsContainer.scrollTop - logsContainer.clientHeight) < 1; logsContainer.appendChild(child); setTimeout(() => {