dozzle icon indicating copy to clipboard operation
dozzle copied to clipboard

Add filter for log levels

Open Corbie-42 opened this issue 1 year ago • 10 comments

The log level detection is already working fine. Now it would be great, if we could filter the output by log level. Every level should be filterable individually.

Corbie-42 avatar Oct 20 '23 07:10 Corbie-42

Yea, that's a good idea. But there is an issue why I didn't implement this. Right now, I guess the level. https://github.com/amir20/dozzle/blob/021d3f7a9938d81878d9ad71ec2dc36384f7e2a6/docker/level_guesser.go#L11-L33

I use a combination of regex and filters to check for level. It could totally be wrong. I haven't implemented this because I don't think I am always right. So what should happen to the filtering when it can't find the level?

Example would be say there are 4 lines, WARN, WARN, INFO, NO_LEVEL. If I filter by WARN, should it not show NO_LEVEL too?

amir20 avatar Oct 20 '23 16:10 amir20

Perhaps rather than treating as levels (as proper logging would, where you'd see that level and anything higher but nothing lower) you could instead treat them more like custom filters in Excel where the user could pick any combination of them that they want by ticking/unticking them? Hope that makes some sense!

EDIflyer avatar Oct 21 '23 07:10 EDIflyer

Maybe you can treat NO_LEVEL just like the level detected above. This often happens, if a log entry consists of multiple lines, like a stack trace.

You could also make it a option to treat such entries differently and show/hide them on demand.

@EDIflyer that's what I meant 😊

Corbie-42 avatar Oct 21 '23 09:10 Corbie-42

I think it would be weird if someone is filtering by INFO and then WARN doesn't show up. What do other tools do? Does anybody have examples?

amir20 avatar Oct 23 '23 01:10 amir20

You can have a look at the Chrome developer console. There the log levels can be selected individually.

Corbie-42 avatar Oct 23 '23 07:10 Corbie-42

Ah yes, good idea of an example! image

EDIflyer avatar Oct 23 '23 10:10 EDIflyer

This is the javascript console right? I think with JS, you can only have console.log, console.error and console.warnings so that makes sense.

But perhaps this is good enough and one option could be undefined levels.

I'll keep thinking about this. Gotta finish the mult-user authentication first. :)

amir20 avatar Oct 27 '23 02:10 amir20

Yep just the standard console in Chrome - It covers non JS things too (CSS, etc.) that might be why it has those other levels... image

EDIflyer avatar Oct 27 '23 12:10 EDIflyer

There is also console.debug in JavaScript, that's what they mean by "verbose" . In some languages "verbose" is the same as "trace", which are both one level below "debug" in that case. So there is no common usage. There are also higher levels like "fatal" in some languages.

Corbie-42 avatar Oct 29 '23 10:10 Corbie-42

Most log tooling I've used will track what log levels it has detected and allow you to select from those that it has seen. The UI shows a toggle list of levels its seen so that the user is able to select those they deem important. You can then select a series of levels or a single level if you know what you're filtering for.

I don't feel as though Dozzle should decided what level is more important than another... considering that some systems use "critical", "emergency" or "serious" as log levels; but who knows what order they should appear! And then you can have a single container running multiple applications, each with their own log levels, this becomes even more confusing.

So getting back to KISS methodology, detect any level, allow user to choose those they want.

In my opinion the only aspect of log levels that Dozzle may be opinionated about is ordering and colouring that appear in the list it has detected.

madrussa avatar May 17 '24 10:05 madrussa