Switch verbosity macros to use group argument#73
Merged
Conversation
As noted in [this comment](https://github.com/JuliaLogging/LoggingExtras.jl/pull/64/files#r903295686), there's currently a semantic error with the verbosity macros where even if my verbosity is explicitly set to 0 or 1, but my log level is `Info`, then a message like: ```julia @errorv 2 "more detailed error message than you normally want to see" ``` will still be logged, since the current logic just does `Error - 2`. With the change proposed in this PR, we get the following change in behavior: * If `LoggingExtras.withlevel` or an alternative filter doesn't inspect the group.verbosity argument, then the verbose macros act just like the normal logging macros * If `withlevel` _is_ used, then the above case acts as expected; i.e. the `@errorv 2 msg` case only logs if `withlevel(Info; verbosity=2)` is set. I opted to wrap the verbosity level in a new `LoggingExtras.Verbosity` struct so that if the `group` argument is ever used for something else as an `Int`, it won't accidentally conflict with the verbosity filtering. We'll still clobber that argument if anyone else tries to use it, but it shouldn't affect cases where people _aren't_ using the verbosity macros. Fixes JuliaWeb/HTTP.jl#938.
oxinabox
reviewed
Oct 21, 2022
oxinabox
approved these changes
Oct 21, 2022
Member
oxinabox
left a comment
There was a problem hiding this comment.
I am convinced.
I am not sure why i was so opinionated the other way before.
I mean i do still see merit to my argument, but not as much.
(Aside: I continue to thinkg that the group should be something that acts kind of like an AbstractSet, so you can add multiple things and then check if any things are contained in it. But that is orthogonal to this PR)
I only have one small comment, (applies to multiple bits of the code)
address that as you see fit and merge when happy.
I think lets not tag a release with this, since as you say it is breaking.
but with this done we will be able to tag 1.0
(once we also do #70)
Co-authored-by: Frames Catherine White <oxinabox@ucc.asn.au>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As noted in this comment, there's currently a semantic error with the verbosity macros where even if my verbosity is explicitly set to 0 or 1, but my log level is
Info, then a message like:will still be logged, since the current logic just does
Error - 2.With the change proposed in this PR, we get the following change in behavior:
LoggingExtras.withlevelor an alternative filter doesn't inspect the group.verbosity argument, then the verbose macros act just like the normal logging macroswithlevelis used, then the above case acts as expected; i.e. the@errorv 2 msgcase only logs ifwithlevel(Info; verbosity=2)is set.I opted to wrap the verbosity level in a new
LoggingExtras.Verbositystruct so that if thegroupargument is ever used for something else as anInt, it won't accidentally conflict with the verbosity filtering. We'll still clobber that argument if anyone else tries to use it, but it shouldn't affect cases where people aren't using the verbosity macros.Fixes JuliaWeb/HTTP.jl#938.