mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
[LOG] add filter
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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';
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user