[LOG] add filter

This commit is contained in:
chromoxdor
2026-01-23 13:51:47 +01:00
parent 65abd14751
commit e60b08539b
2 changed files with 27 additions and 1 deletions
+2
View File
@@ -6,6 +6,7 @@
#include "../WebServer/JSON.h"
#include "../WebServer/Markup.h"
#include "../WebServer/Markup_Buttons.h"
#include "../WebServer/Markup_Forms.h"
#include "../DataStructs/LogBuffer.h"
#include "../DataStructs/TimingStats.h"
@@ -35,6 +36,7 @@ void handle_log() {
"</TR></table><div id='current_loglevel' style='font-weight: bold;'>Logging: </div><div class='logviewer' id='copyText_1'></div>"));
addHtml(F("Autoscroll: "));
addCheckBox(F("autoscroll"), true);
addFormTextBox(F("Filter"), F("logfilter"), "", 30);
addHtml(F("<BR></body>"));
serve_JS(JSfiles_e::FetchAndParseLog);
+25 -1
View File
@@ -1,5 +1,5 @@
function elId(e) {
return document.getElementById(e);
return document.getElementById(e);
}
function getBrowser() {
var ua = navigator.userAgent,
@@ -96,6 +96,7 @@ function loopDeLoop(timeForNext, activeRequests) {
elId(ct1).innerHTML = '';
}
elId(ct1).innerHTML += logEntriesChunk;
applyLogFilter();
}
logEntriesChunk = '';
autoscroll_on = elId('autoscroll').checked;
@@ -121,4 +122,27 @@ function loopDeLoop(timeForNext, activeRequests) {
};
check = 1;
}, timeForNext);
}
function applyLogFilter() {
const filtername = elId('logfilter').value;
// prepare filters: "string1;string2"
const filters = filtername
.split(';')
.map(s => s.trim().toLowerCase())
.filter(Boolean);
const container = document.getElementById('copyText_1');
const entries = container.querySelectorAll('div');
entries.forEach(entry => {
const text = entry.textContent.toLowerCase();
const matches =
filters.length === 0 || filters.some(f => text.includes(f));
// show only matching entries
entry.style.display = matches ? '' : 'none';
});
}