Make logging filters work again by moving EnvFilter into its own layer #147613
+5
−4
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.
tracing
at the time of writing has a feature (?) in its Filter implementation, so that filters like EnvFilter are consulted for status of a span or event and whether it is marked as interesting for logging. Combining a Filter with another layer through thewith_filter
combinator produces a filtered layer that enables an event unless it is statically determined that the event is uninteresting. However, if the filter is dynamic, because of filtering on span names or field values as an example, events are always enabled by design. There is anevent_enabled
predicate onEnvFilter
implementation but it falls back to default and, thus, the dynamic filters are unused.Previously,
RUSTC_LOG=[]
orRUSTC_LOG=[garbage]
enables all events, even when spans do not match.This patch re-enables span- and field-based filters. With
RUSTC_LOG=[garbage]
one should expect no events are enabled again. This will help with development greatly because we can meaningfully filter internal logs again.