-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
properly handle the off
pseudo-level in presence of nested logging directives
#605
Conversation
…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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we compare the module names on the byte-level and not as strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with std, this should read .to_string
.
pub(super) fn to_str(&self) -> String { | |
pub(super) fn to_string(&self) -> String { |
bors r=Urhengulas |
Build succeeded: |
this handles nested logging directives like:
by treating the
off
pseudo-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: