properly handle the off pseudo-level in presence of nested logging directives#605
Merged
properly handle the off pseudo-level in presence of nested logging directives#605
off pseudo-level in presence of nested logging directives#605Conversation
…directives this handles nested logging directives like: ``` $ # NOTE the order of these directives doesn't matter $ DEFMT_LOG=krate=info,krate::module=off,krate::module::inner=info ``` by treating the `off` pseudo-level as a explicit "reject" criteria and checking logging directives from the innermost one (the one that has more module path segments) to the outermost ones
Urhengulas
approved these changes
Oct 11, 2021
Member
Urhengulas
left a comment
There was a problem hiding this comment.
Looks good. But I didn't fully understand the the code and mainly checked if the tests make sense.
And I added one question and one change request :)
| // `module_path!` returns the path to the module the function is in, not the path to the function | ||
| // itself | ||
| fn codegen_is_inside_of_check(parent_module_path: &str) -> TokenStream2 { | ||
| let parent = parent_module_path.as_bytes(); |
Member
There was a problem hiding this comment.
Why do we compare the module names on the byte-level and not as strings?
Member
Author
There was a problem hiding this comment.
at the end we want to do str::starts_with in const context but that method cannot be used in const context so instead we do a byte by byte equality check (see the macro expansion). we cannot index into a str and get a u8 so instead we use [u8] slices
|
|
||
| pub(crate) fn as_str(&self) -> &str { | ||
| &self.0 | ||
| pub(super) fn to_str(&self) -> String { |
Member
There was a problem hiding this comment.
For consistency with std, this should read .to_string.
Suggested change
| pub(super) fn to_str(&self) -> String { | |
| pub(super) fn to_string(&self) -> String { |
Member
Author
|
bors r=Urhengulas |
Contributor
|
Build succeeded: |
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.
this handles nested logging directives like:
by treating the
offpseudo-level as a explicit "reject" criteria and checking logging directivesfrom the innermost one (the one that has more module path segments) to the outermost ones
manually tested with: