-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter leveled logging below a set level #250
Comments
@bishoprook I would like to see a good implementation of this idea in the log/levels package. I will gladly review a PR along these lines. The approach taken by log15 is to filter the log events after they enter the logging stack with Implementing level filtering directly in My preference is for the first approach but that could change once we see what the code looks like. |
See the PR I just submitted and let me know what you think. :) |
This is now accomplished with level.Options. |
Apologies if this is something that's been dealt with before but I couldn't find it in past issues or PRs.
If I set up a leveled logger and do some leveled log statements e.g.:
I would want the ability to set a log level above which I receive the log statements but below which they're discarded. Something like:
This saves a bit of CPU and I/O cost. It's a feature that log15 had, seems it just never came over here.
Also, you could prevent the evaluation of
Valuer
s, so I can do:...but if the log level is set to Info or above, not only does this line not get evaluated,
someExpensiveOp
never gets called.I'm game to do the work and send the PR if this sounds like something desirable!
The text was updated successfully, but these errors were encountered: