Skip to content

Conversation

@chromoxdor
Copy link
Contributor

@chromoxdor chromoxdor commented Jan 23, 2026

Made a filter. It was easier than I thought :)
Should I make the changes optional/custom?

  • Filter the log by strings.
  • Multiple filter are separated by ;.
  • Exclude phrases with !.
  • AND operator for linking phrases &.
nofilter onestring two strings

@chromoxdor chromoxdor changed the title [LOG] Adding a Filter for the weblog [LOG] Adding a filter for the weblog Jan 23, 2026
@chromoxdor
Copy link
Contributor Author

Should i also change the functions in WebStaticData.h? Or leave it to save space?
Also, I was also thinking of extending the filter functionality to the copyClipboard function. It seems this function is not loaded externally and is also not read when the JS file is copied onto the ESP, so here I definitely would need to change the function in WebStaticData.h.

@tonhuisman
Copy link
Contributor

Should i also change the functions in WebStaticData.h? Or leave it to save space?

That WebStaticData.h data is only included in the non-LIMIT_BUILD_SIZE builds, AFAICS, so updating the minified version there would be helpful 😉

FR: Can this search (also) handle wildcards or regular expressions?

@chromoxdor
Copy link
Contributor Author

chromoxdor commented Jan 23, 2026

FR: Can this search (also) handle wildcards or regular expressions?

No, I wanted it to be as simple and small as possible, but this can surely be added.
What exactly do we really need?

wildcards

This is basically included since it filters also phrases. At least in my understanding.

@chromoxdor
Copy link
Contributor Author

I might want to add an option to show an x number of lines after a matching line. But not sure how to flag this as an option in the filter field (also not sure if it is really necessary. I am actually quite happy with how it works now).

@TD-er
Copy link
Member

TD-er commented Jan 23, 2026

You could also add a CTRL-F like option to move to the lines and then add an attribute to those lines to highlight the parts where it occurs.
Similar to how many text editors help highlight search results. (and also grep does)

@chromoxdor
Copy link
Contributor Author

chromoxdor commented Jan 23, 2026

lines to highlight the parts where it occurs.

Like so?:
Bildschirmfoto 2026-01-23 um 15 41 55

Edit:
BTW, just realizing ACT : vs EVENT: (after ACT there are two spaces)

@tonhuisman
Copy link
Contributor

tonhuisman commented Jan 23, 2026

BTW, just realizing ACT : vs EVENT: (after ACT there are two spaces)

The intent is to have the console log nicely aligned, but 5 characters is not enough to hold BME280 f.e. (also an issue with some other plugins) 🫣

@chromoxdor
Copy link
Contributor Author

chromoxdor commented Jan 23, 2026

Ok.. for now we have:
; -> acts as an OR (I used this for convenience instead of |)
& -> acts as an AND (it uses strict order)

I chose this over standard regex so that mere mortal people can use it too. :)

@TD-er
Copy link
Member

TD-er commented Jan 23, 2026

lines to highlight the parts where it occurs.

Like so?: Bildschirmfoto 2026-01-23 um 15 41 55

Edit: BTW, just realizing ACT : vs EVENT: (after ACT there are two spaces)

Looking good :)

@TD-er
Copy link
Member

TD-er commented Jan 23, 2026

The idea of the ACT : and EVENT: was indeed to make it more aligned.
However it does also add more to the build size. Not just the 2 spaces, but also because in some pieces of code this prefix-like string is used in many more log lines.

So that's also one reason why I was thinking about splitting this into something else. The idea was to allow for filtering, but now you already have that part 'solved'... ;)

@chromoxdor
Copy link
Contributor Author

One thing was missing :)
Bildschirmfoto 2026-01-23 um 21 49 18

@tonhuisman
Copy link
Contributor

Ah, now we're going somewhere 😆 Just waiting for the code changes 😉

@chromoxdor
Copy link
Contributor Author

Just waiting for the code changes 😉

Comes tomorrow. Right now, I have to find a movie. Which takes all my resources :)
And as if that is not enough, I have to watch it after I find it.

@TD-er
Copy link
Member

TD-er commented Jan 23, 2026

And as if that is not enough, I have to watch it after I find it.

If you can't find it, you can watch a YouTube short... and then continue ;)

- Added highlight filter phrases
- Added ordered AND operator (&)
- Added exclusion (!)
@chromoxdor
Copy link
Contributor Author

Ok, I just committed all the changes. It would be nice if somebody could test it.
I also changed the code in WebStaticData.h but it adds roughly 1.5kbytes. Why not serve this as gzipped array. Maybe someone can assist. because i don't really know where to make the changes for adding the right header.

Also: I am not sure if highlighting is really necessary. If you like it, we keep it.
The copyclipboard button now only copies what is filtered. I think this is a good idea, but if you could think of a reason why not, I will undo.

@TD-er
Copy link
Member

TD-er commented Jan 24, 2026

Well it is hard to add 'context'.
So I think it is good to have copied what you're interested in.

N.B. did you notice you now also get the web log from boot when you access it within 30 sec after boot? (on ESP32, ESP8266 does have a shorter TTL for log entries)

- Added a check to determine if there is already a filter field present; otherwise, add one for older builds.
@chromoxdor
Copy link
Contributor Author

I added a bit of code so that every build can make use of the filter. The script checks first if there is a filter field and if not injects it via the script.
So if you want to test just place the script file fetch_and_parse_log.js onto your device.

@TD-er
Copy link
Member

TD-er commented Jan 25, 2026

Can you also make a commit which removes that one file which is not part of this PR?

@chromoxdor
Copy link
Contributor Author

N.B. did you notice you now also get the web log from boot when you access it within 30 sec after boot? (on ESP32, ESP8266 does have a shorter TTL for log entries)

BTW: This is really cool and helpful! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants