-
Notifications
You must be signed in to change notification settings - Fork 773
Use state machine to parse directives #3243
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
base: v0.1.x
Are you sure you want to change the base?
Conversation
Added
This app sets AFAICT you fixed it and it's nearly free now. |
After this, |
Nice catch, yes! Added that into the first commit. |
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.
Could you please rebase this against master
. We merge everything in there first and then David or I will handle backporting to v0.1.x
.
Before making this change, I think we need more tests to ensure that the behavior isn't changing. Especially because there are things I'm seeing in the code that are different to what the docs say.
I'm happy to have a look at writing some of those tests, but it may take me a little bit to get to it.
"" => (LevelFilter::TRACE, None), | ||
level_or_target => match LevelFilter::from_str(level_or_target) { | ||
Ok(level) => (level, None), | ||
Err(_) => (LevelFilter::TRACE, Some(level_or_target.to_owned())), |
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.
Let's keep the comment that explains why we're picking TRACE
:
Err(_) => (LevelFilter::TRACE, Some(level_or_target.to_owned())), | |
// Setting the target without the level enables every level for that target | |
Err(_) => (LevelFilter::TRACE, Some(level_or_target.to_owned())), |
match state { | ||
LevelOrTarget { start } => { | ||
let (level, target) = match &from[start..] { | ||
"" => (LevelFilter::TRACE, None), |
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.
This appears to match the previous behavior. But it doesn't match the docs (unless this behavior is performed elsewhere):
https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#method.from_default_env
I actually think that before we release this change, we need some more test coverage so we can understand what is really changing. I know this is probably more than you signed up for, so I can try to set some time aside to write some of those tests too if that would help.
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.
I actually think that before we release this change, we need some more test coverage so we can understand what is really changing. I know this is probably more than you signed up for, so I can try to set some time aside to write some of those tests too if that would help.
I don't mind generating more test coverage, can you just make more explicit what you think we need more test coverage for? (As detailed as you want.)
Intended to fix #3174. Have not done any benchmarks yet -- suggestions on how best to approach that are welcome.
This is a little bit more code, but IMO maybe slightly more readable?
It's correct enough that it passes the tests, there might be edge cases that aren't covered but those should be easy to solve.