-
Notifications
You must be signed in to change notification settings - Fork 721
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
Implement subscribe::Filter for Option<Filter> #2407
Merged
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8919fa0
Fully implement Filter for Box<Filter>
jsgf 00e304b
Implement Filter for Option<F: Filter>
jsgf 5540321
Add test for Option<Filter> on subscribers
jsgf 38f5416
Add documentation for Option<Filter>
jsgf 74f94ee
review comment fixes
jsgf bca61af
Merge branch 'master' into option-layer-filter
davidbarsky b447e17
address more review comments
jsgf 7a6bb31
Add tests and tweak `None` filter interest level
ryanthomasjohnson 8568d96
Merge pull request #1 from ryanthomasjohnson/ryantj/option-layer-filter
jsgf 1b7b671
Merge branch 'tokio-rs:master' into option-layer-filter
jsgf 59cba8c
Run cargo fmt
jsgf dfd857a
Merge branch 'master' into option-layer-filter
davidbarsky 29d15d4
Merge branch 'master' into option-layer-filter
hawkw 883c594
Fix clippy warning
jsgf 01be443
Merge branch 'master' into option-layer-filter
davidbarsky 6507da9
Merge branch 'master' into option-layer-filter
davidbarsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#![cfg(feature = "registry")] | ||
mod filter_scopes; | ||
mod option; | ||
mod per_event; | ||
mod targets; | ||
mod trees; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use super::*; | ||
use tracing_subscriber::{filter, prelude::*, Subscribe}; | ||
|
||
fn filter_out_everything<S>() -> filter::DynFilterFn<S> { | ||
// Use dynamic filter fn to disable interest caching and max-level hints, | ||
// allowing us to put all of these tests in the same file. | ||
filter::dynamic_filter_fn(|_, _| false) | ||
} | ||
|
||
#[test] | ||
fn option_some() { | ||
let (subscribe, handle) = subscriber::mock().only().run_with_handle(); | ||
let subscribe = subscribe.with_filter(Some(filter_out_everything())); | ||
|
||
let _guard = tracing_subscriber::registry().with(subscribe).set_default(); | ||
|
||
for i in 0..2 { | ||
tracing::info!(i); | ||
} | ||
|
||
handle.assert_finished(); | ||
} | ||
|
||
#[test] | ||
fn option_none() { | ||
let (subscribe, handle) = subscriber::mock() | ||
.event(expect::event()) | ||
.event(expect::event()) | ||
.only() | ||
.run_with_handle(); | ||
let subscribe = Box::new(subscribe.with_filter(None::<filter::DynFilterFn<_>>)); | ||
|
||
let _guard = tracing_subscriber::registry().with(subscribe).set_default(); | ||
|
||
for i in 0..2 { | ||
tracing::info!(i); | ||
} | ||
|
||
handle.assert_finished(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's also add some tests where a registry includes a subscriber that has an |
||
} |
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.
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.
it could maybe be nice to have an example somewhere showing how and why we might want to use the
Filter
impl forOption
?