-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Motivation Currently, when using the `Layer` impl for `Option<S: Layer<...>>`, the `Layer::max_level_hint` returns `Some(LevelFilter::OFF)`. This was intended to allow totally disabling output in the case where a `Subscriber` is composed entirely of `None` `Layer`s. However, when other `Layer`s *do* exist but return `None` from their `max_level_hint` implementations to indicate that they don't care what the max level is, the presence of a single `None` layer will globally disable everything, which is not the wanted behavior. Fixes #2265 ## Solution This branch introduces a special downcast marker that can be used to detect when a `Layer` in a `Layered` is `None`. This allows the `pick_level_hint` method to short-circuit when a `Layer` implementation which is `None` returns `Some(LevelFilter::OFF)` from its `max_level_hint` if the other half of the `Layered` is not `None`. The tests I added should be pretty thorough! Additionally, the downcast marker is special-cased in the `reload` `Layer`. Normally, this `Layer` doesn't support downcasting, but it can in the case of the special marker value. Co-authored-by: Eliza Weisman <[email protected]>
- Loading branch information
Showing
4 changed files
with
323 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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