tracing
tracing copied to clipboard
Add `EnvFilter::from_directives`
Motivation
I was using an EnvFilter within a tracing_subscriber::reload layer, to be able to change the filter at runtime via a config file.
Here, I let the deserialization take care of validating the correctness of the configured filter directives.
However, there wasn't a straightforward way to construct the EnvFilter via already parsed directives.
Solution
There is a private from_directives method on the Builder, which was already considered by @hawkw to be made public.
Instead, I opted to creating a new, similar method directly on the EnvFilter.
This should be easier to discover and more convenient than having to call EnvFilter::builder().from_directives().
Though, we could consider making both variants public.
This is my first contribution to tokio, so let me know if something is missing from the PR!
Thank you! I’m happy to see a PR to make such an API public. For what it’s worth, I was looking for it, but ended up parsing strings instead.
Are there any blockers to getting this merged besides the branch being out-of-date? Just bumped into this, I can make an updated the PR if the sentiment hasn't changed and @Plebshot doesn't mind
No blockers, it only awaits review as far as I know. I just synced the fork to be up to date though. Thanks for the reminder.