JuliaLogging / ProgressLogging.jl

MIT License
50 stars 8 forks source link

Use _group/_id/level to make it easier to filter out progress log events? #9

Open tkf opened 5 years ago

tkf commented 5 years ago

Currently there is no easy way to filter out progress log events using Logging.shouldlog API. This becomes annoying when using JULIA_DEBUG.

We can fix this by specifying a custom _group. Quoting Logging.@logmsg:

_group=symbol can be used to override the message group (this is normally derived from the base name of the source file).

It seems to be a right thing to use here. @c42f Does this match with the design of Logging?

We'd able to use EarlyFilteredLogger from LoggingExtras.jl if we implement this.

c42f commented 5 years ago

Thanks for the ping. The meaning of _group has never been very clearly defined. Currently the default value (based on file name) means it's basically a software-component based category generally finer than Module. What you're proposing here feels like it might be a custom log level to me, and the story there is incomplete. My current opinion is that there are two types of categories people care about in logging; see https://github.com/JuliaLang/julia/issues/33418#issuecomment-537015137.

However, we don't have a consensus yet and it's possible we should just clarify or generalize _group somehow; perhaps allow it to be a tuple represented as a set of symbols or some such. I'd welcome your input at https://github.com/JuliaLang/julia/issues/33418 :-)

devmotion commented 4 years ago

Is there any consensus on how to handle this yet? I think being able to filter progress log events would be great as it would improve composability of loggers and avoid manually forwarding non-progress logs as in https://github.com/JunoLab/Atom.jl/blob/bf6c20ebfe54ea444ea998f9f58402da2731d31a/src/progress.jl#L61-L67.

tkf commented 4 years ago

Since _group is documented to be a symbol, and there is just single global namespace, I'm not sure about using it for the filtering now. I think using custom type for logging level (https://github.com/JuliaLang/julia/issues/33418, https://github.com/JuliaLang/julia/pull/33960) may be a better approach.

tkf commented 4 years ago

...although the same docstring says _id=symbol which does not mean _id has to be a symbol.

tkf commented 4 years ago

Another idea is to use the type of _id: https://github.com/JuliaLang/julia/issues/33418#issuecomment-595637500