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
Changes from 4 commits
8919fa0
00e304b
5540321
38f5416
74f94ee
bca61af
b447e17
7a6bb31
8568d96
1b7b671
59cba8c
dfd857a
29d15d4
883c594
01be443
6507da9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||
use super::*; | ||||||
use tracing_subscriber::{filter, prelude::*, Subscribe}; | ||||||
|
||||||
fn filter<S>() -> filter::DynFilterFn<S> { | ||||||
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. small nit, since it took me a second to understand what was happening here:
Suggested change
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. Ditto copied from |
||||||
// 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 = Box::new(subscribe.with_filter(Some(filter()))); | ||||||
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. nit: i'm not sure if 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. I copied |
||||||
|
||||||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
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.
aww, i like the
(surprise!)
:(