dozzle
dozzle copied to clipboard
Add filter for log levels
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.
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?
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!
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 😊
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?
You can have a look at the Chrome developer console. There the log levels can be selected individually.
Ah yes, good idea of an example!
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. :)
Yep just the standard console in Chrome - It covers non JS things too (CSS, etc.) that might be why it has those other levels...
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.
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.