summaryrefslogtreecommitdiffstats
path: root/vendor/tracing-subscriber/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/tracing-subscriber/tests/cached_layer_filters_dont_break_other_layers.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/cached_layer_filters_dont_break_other_layers.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/duplicate_spans.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/duplicate_spans.rs)1
-rw-r--r--vendor/tracing-subscriber/tests/env_filter/main.rs547
-rw-r--r--vendor/tracing-subscriber/tests/env_filter/per_layer.rs305
-rw-r--r--vendor/tracing-subscriber/tests/event_enabling.rs81
-rw-r--r--vendor/tracing-subscriber/tests/field_filter.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/field_filter.rs)4
-rw-r--r--vendor/tracing-subscriber/tests/filter_log.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/filter_log.rs)4
-rw-r--r--vendor/tracing-subscriber/tests/fmt_max_level_hint.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/fmt_max_level_hint.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/hinted_layer_filters_dont_break_other_layers.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/hinted_layer_filters_dont_break_other_layers.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/layer_filter_interests_are_cached.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/layer_filter_interests_are_cached.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/boxed.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/layer_filters/boxed.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/combinators.rs42
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/downcast_raw.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/layer_filters/downcast_raw.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/filter_scopes.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/layer_filters/filter_scopes.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/main.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/layer_filters/main.rs)4
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/per_event.rs61
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/targets.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/layer_filters/targets.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/trees.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/layer_filters/trees.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/layer_filters/vec.rs120
-rw-r--r--vendor/tracing-subscriber/tests/multiple_layer_filter_interests_cached.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/multiple_layer_filter_interests_cached.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/option.rs262
-rw-r--r--vendor/tracing-subscriber/tests/registry_max_level_hint.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/registry_max_level_hint.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/registry_with_subscriber.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/registry_with_subscriber.rs)2
-rw-r--r--vendor/tracing-subscriber/tests/reload.rs155
-rw-r--r--vendor/tracing-subscriber/tests/same_len_filters.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/same_len_filters.rs)4
-rw-r--r--vendor/tracing-subscriber/tests/support.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/support.rs)19
-rw-r--r--vendor/tracing-subscriber/tests/unhinted_layer_filters_dont_break_other_layers.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/unhinted_layer_filters_dont_break_other_layers.rs)0
-rw-r--r--vendor/tracing-subscriber/tests/utils.rs (renamed from vendor/tracing-subscriber-0.3.3/tests/utils.rs)4
-rw-r--r--vendor/tracing-subscriber/tests/vec.rs19
-rw-r--r--vendor/tracing-subscriber/tests/vec_subscriber_filter_interests_cached.rs117
30 files changed, 1728 insertions, 23 deletions
diff --git a/vendor/tracing-subscriber-0.3.3/tests/cached_layer_filters_dont_break_other_layers.rs b/vendor/tracing-subscriber/tests/cached_layer_filters_dont_break_other_layers.rs
index 00e98a994..00e98a994 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/cached_layer_filters_dont_break_other_layers.rs
+++ b/vendor/tracing-subscriber/tests/cached_layer_filters_dont_break_other_layers.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/duplicate_spans.rs b/vendor/tracing-subscriber/tests/duplicate_spans.rs
index c4a736f74..5d4dc6a85 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/duplicate_spans.rs
+++ b/vendor/tracing-subscriber/tests/duplicate_spans.rs
@@ -1,5 +1,4 @@
#![cfg(all(feature = "env-filter", feature = "fmt"))]
-mod support;
use tracing::{self, subscriber::with_default, Span};
use tracing_subscriber::{filter::EnvFilter, FmtSubscriber};
diff --git a/vendor/tracing-subscriber/tests/env_filter/main.rs b/vendor/tracing-subscriber/tests/env_filter/main.rs
new file mode 100644
index 000000000..3c3d4868b
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/env_filter/main.rs
@@ -0,0 +1,547 @@
+#![cfg(feature = "env-filter")]
+
+#[path = "../support.rs"]
+mod support;
+use self::support::*;
+
+mod per_layer;
+
+use tracing::{self, subscriber::with_default, Level};
+use tracing_subscriber::{
+ filter::{EnvFilter, LevelFilter},
+ prelude::*,
+};
+
+#[test]
+fn level_filter_event() {
+ let filter: EnvFilter = "info".parse().expect("filter should parse");
+ let (subscriber, finished) = subscriber::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::ERROR))
+ .done()
+ .run_with_handle();
+ let subscriber = subscriber.with(filter);
+
+ with_default(subscriber, || {
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "foo", "this should also be disabled");
+ tracing::warn!(target: "foo", "this should be enabled");
+ tracing::error!("this should be enabled too");
+ });
+
+ finished.assert_finished();
+}
+
+#[test]
+fn same_name_spans() {
+ let filter: EnvFilter = "[foo{bar}]=trace,[foo{baz}]=trace"
+ .parse()
+ .expect("filter should parse");
+ let (subscriber, finished) = subscriber::mock()
+ .new_span(
+ span::mock()
+ .named("foo")
+ .at_level(Level::TRACE)
+ .with_field(field::mock("bar")),
+ )
+ .new_span(
+ span::mock()
+ .named("foo")
+ .at_level(Level::TRACE)
+ .with_field(field::mock("baz")),
+ )
+ .done()
+ .run_with_handle();
+ let subscriber = subscriber.with(filter);
+ with_default(subscriber, || {
+ tracing::trace_span!("foo", bar = 1);
+ tracing::trace_span!("foo", baz = 1);
+ });
+
+ finished.assert_finished();
+}
+
+#[test]
+fn level_filter_event_with_target() {
+ let filter: EnvFilter = "info,stuff=debug".parse().expect("filter should parse");
+ let (subscriber, finished) = subscriber::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::DEBUG).with_target("stuff"))
+ .event(event::mock().at_level(Level::WARN).with_target("stuff"))
+ .event(event::mock().at_level(Level::ERROR))
+ .event(event::mock().at_level(Level::ERROR).with_target("stuff"))
+ .done()
+ .run_with_handle();
+ let subscriber = subscriber.with(filter);
+
+ with_default(subscriber, || {
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "stuff", "this should be enabled");
+ tracing::debug!("but this shouldn't");
+ tracing::trace!(target: "stuff", "and neither should this");
+ tracing::warn!(target: "stuff", "this should be enabled");
+ tracing::error!("this should be enabled too");
+ tracing::error!(target: "stuff", "this should be enabled also");
+ });
+
+ finished.assert_finished();
+}
+
+#[test]
+fn level_filter_event_with_target_and_span_global() {
+ let filter: EnvFilter = "info,stuff[cool_span]=debug"
+ .parse()
+ .expect("filter should parse");
+
+ let cool_span = span::named("cool_span");
+ let uncool_span = span::named("uncool_span");
+ let (subscriber, handle) = subscriber::mock()
+ .enter(cool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![cool_span.clone()]),
+ )
+ .exit(cool_span)
+ .enter(uncool_span.clone())
+ .exit(uncool_span)
+ .done()
+ .run_with_handle();
+
+ let subscriber = subscriber.with(filter);
+
+ with_default(subscriber, || {
+ {
+ let _span = tracing::info_span!(target: "stuff", "cool_span").entered();
+ tracing::debug!("this should be enabled");
+ }
+
+ tracing::debug!("should also be disabled");
+
+ {
+ let _span = tracing::info_span!("uncool_span").entered();
+ tracing::debug!("this should be disabled");
+ }
+ });
+
+ handle.assert_finished();
+}
+
+#[test]
+fn not_order_dependent() {
+ // this test reproduces tokio-rs/tracing#623
+
+ let filter: EnvFilter = "stuff=debug,info".parse().expect("filter should parse");
+ let (subscriber, finished) = subscriber::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::DEBUG).with_target("stuff"))
+ .event(event::mock().at_level(Level::WARN).with_target("stuff"))
+ .event(event::mock().at_level(Level::ERROR))
+ .event(event::mock().at_level(Level::ERROR).with_target("stuff"))
+ .done()
+ .run_with_handle();
+ let subscriber = subscriber.with(filter);
+
+ with_default(subscriber, || {
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "stuff", "this should be enabled");
+ tracing::debug!("but this shouldn't");
+ tracing::trace!(target: "stuff", "and neither should this");
+ tracing::warn!(target: "stuff", "this should be enabled");
+ tracing::error!("this should be enabled too");
+ tracing::error!(target: "stuff", "this should be enabled also");
+ });
+
+ finished.assert_finished();
+}
+
+#[test]
+fn add_directive_enables_event() {
+ // this test reproduces tokio-rs/tracing#591
+
+ // by default, use info level
+ let mut filter = EnvFilter::new(LevelFilter::INFO.to_string());
+
+ // overwrite with a more specific directive
+ filter = filter.add_directive("hello=trace".parse().expect("directive should parse"));
+
+ let (subscriber, finished) = subscriber::mock()
+ .event(event::mock().at_level(Level::INFO).with_target("hello"))
+ .event(event::mock().at_level(Level::TRACE).with_target("hello"))
+ .done()
+ .run_with_handle();
+ let subscriber = subscriber.with(filter);
+
+ with_default(subscriber, || {
+ tracing::info!(target: "hello", "hello info");
+ tracing::trace!(target: "hello", "hello trace");
+ });
+
+ finished.assert_finished();
+}
+
+#[test]
+fn span_name_filter_is_dynamic() {
+ let filter: EnvFilter = "info,[cool_span]=debug"
+ .parse()
+ .expect("filter should parse");
+ let (subscriber, finished) = subscriber::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .enter(span::named("cool_span"))
+ .event(event::mock().at_level(Level::DEBUG))
+ .enter(span::named("uncool_span"))
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::DEBUG))
+ .exit(span::named("uncool_span"))
+ .exit(span::named("cool_span"))
+ .enter(span::named("uncool_span"))
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::ERROR))
+ .exit(span::named("uncool_span"))
+ .done()
+ .run_with_handle();
+ let subscriber = subscriber.with(filter);
+
+ with_default(subscriber, || {
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ let cool_span = tracing::info_span!("cool_span");
+ let uncool_span = tracing::info_span!("uncool_span");
+
+ {
+ let _enter = cool_span.enter();
+ tracing::debug!("i'm a cool event");
+ tracing::trace!("i'm cool, but not cool enough");
+ let _enter2 = uncool_span.enter();
+ tracing::warn!("warning: extremely cool!");
+ tracing::debug!("i'm still cool");
+ }
+
+ let _enter = uncool_span.enter();
+ tracing::warn!("warning: not that cool");
+ tracing::trace!("im not cool enough");
+ tracing::error!("uncool error");
+ });
+
+ finished.assert_finished();
+}
+
+#[test]
+fn method_name_resolution() {
+ #[allow(unused_imports)]
+ use tracing_subscriber::layer::{Filter, Layer};
+
+ let filter = EnvFilter::new("hello_world=info");
+ filter.max_level_hint();
+}
+
+// contains the same tests as the first half of this file
+// but using EnvFilter as a `Filter`, not as a `Layer`
+mod per_layer_filter {
+ use super::*;
+
+ #[test]
+ fn level_filter_event() {
+ let filter: EnvFilter = "info".parse().expect("filter should parse");
+ let (layer, handle) = layer::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::ERROR))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "foo", "this should also be disabled");
+ tracing::warn!(target: "foo", "this should be enabled");
+ tracing::error!("this should be enabled too");
+
+ handle.assert_finished();
+ }
+
+ #[test]
+ fn same_name_spans() {
+ let filter: EnvFilter = "[foo{bar}]=trace,[foo{baz}]=trace"
+ .parse()
+ .expect("filter should parse");
+ let (layer, handle) = layer::mock()
+ .new_span(
+ span::mock()
+ .named("foo")
+ .at_level(Level::TRACE)
+ .with_field(field::mock("bar")),
+ )
+ .new_span(
+ span::mock()
+ .named("foo")
+ .at_level(Level::TRACE)
+ .with_field(field::mock("baz")),
+ )
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace_span!("foo", bar = 1);
+ tracing::trace_span!("foo", baz = 1);
+
+ handle.assert_finished();
+ }
+
+ #[test]
+ fn level_filter_event_with_target() {
+ let filter: EnvFilter = "info,stuff=debug".parse().expect("filter should parse");
+ let (layer, handle) = layer::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::DEBUG).with_target("stuff"))
+ .event(event::mock().at_level(Level::WARN).with_target("stuff"))
+ .event(event::mock().at_level(Level::ERROR))
+ .event(event::mock().at_level(Level::ERROR).with_target("stuff"))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "stuff", "this should be enabled");
+ tracing::debug!("but this shouldn't");
+ tracing::trace!(target: "stuff", "and neither should this");
+ tracing::warn!(target: "stuff", "this should be enabled");
+ tracing::error!("this should be enabled too");
+ tracing::error!(target: "stuff", "this should be enabled also");
+
+ handle.assert_finished();
+ }
+
+ #[test]
+ fn level_filter_event_with_target_and_span() {
+ let filter: EnvFilter = "stuff[cool_span]=debug"
+ .parse()
+ .expect("filter should parse");
+
+ let cool_span = span::named("cool_span");
+ let (layer, handle) = layer::mock()
+ .enter(cool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![cool_span.clone()]),
+ )
+ .exit(cool_span)
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ {
+ let _span = tracing::info_span!(target: "stuff", "cool_span").entered();
+ tracing::debug!("this should be enabled");
+ }
+
+ tracing::debug!("should also be disabled");
+
+ {
+ let _span = tracing::info_span!("uncool_span").entered();
+ tracing::debug!("this should be disabled");
+ }
+
+ handle.assert_finished();
+ }
+
+ #[test]
+ fn not_order_dependent() {
+ // this test reproduces tokio-rs/tracing#623
+
+ let filter: EnvFilter = "stuff=debug,info".parse().expect("filter should parse");
+ let (layer, finished) = layer::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::DEBUG).with_target("stuff"))
+ .event(event::mock().at_level(Level::WARN).with_target("stuff"))
+ .event(event::mock().at_level(Level::ERROR))
+ .event(event::mock().at_level(Level::ERROR).with_target("stuff"))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "stuff", "this should be enabled");
+ tracing::debug!("but this shouldn't");
+ tracing::trace!(target: "stuff", "and neither should this");
+ tracing::warn!(target: "stuff", "this should be enabled");
+ tracing::error!("this should be enabled too");
+ tracing::error!(target: "stuff", "this should be enabled also");
+
+ finished.assert_finished();
+ }
+
+ #[test]
+ fn add_directive_enables_event() {
+ // this test reproduces tokio-rs/tracing#591
+
+ // by default, use info level
+ let mut filter = EnvFilter::new(LevelFilter::INFO.to_string());
+
+ // overwrite with a more specific directive
+ filter = filter.add_directive("hello=trace".parse().expect("directive should parse"));
+
+ let (layer, finished) = layer::mock()
+ .event(event::mock().at_level(Level::INFO).with_target("hello"))
+ .event(event::mock().at_level(Level::TRACE).with_target("hello"))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::info!(target: "hello", "hello info");
+ tracing::trace!(target: "hello", "hello trace");
+
+ finished.assert_finished();
+ }
+
+ #[test]
+ fn span_name_filter_is_dynamic() {
+ let filter: EnvFilter = "info,[cool_span]=debug"
+ .parse()
+ .expect("filter should parse");
+ let cool_span = span::named("cool_span");
+ let uncool_span = span::named("uncool_span");
+ let (layer, finished) = layer::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .enter(cool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![cool_span.clone()]),
+ )
+ .enter(uncool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::WARN)
+ .in_scope(vec![uncool_span.clone()]),
+ )
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![uncool_span.clone()]),
+ )
+ .exit(uncool_span.clone())
+ .exit(cool_span)
+ .enter(uncool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::WARN)
+ .in_scope(vec![uncool_span.clone()]),
+ )
+ .event(
+ event::mock()
+ .at_level(Level::ERROR)
+ .in_scope(vec![uncool_span.clone()]),
+ )
+ .exit(uncool_span)
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ let cool_span = tracing::info_span!("cool_span");
+ let uncool_span = tracing::info_span!("uncool_span");
+
+ {
+ let _enter = cool_span.enter();
+ tracing::debug!("i'm a cool event");
+ tracing::trace!("i'm cool, but not cool enough");
+ let _enter2 = uncool_span.enter();
+ tracing::warn!("warning: extremely cool!");
+ tracing::debug!("i'm still cool");
+ }
+
+ {
+ let _enter = uncool_span.enter();
+ tracing::warn!("warning: not that cool");
+ tracing::trace!("im not cool enough");
+ tracing::error!("uncool error");
+ }
+
+ finished.assert_finished();
+ }
+
+ #[test]
+ fn multiple_dynamic_filters() {
+ // Test that multiple dynamic (span) filters only apply to the layers
+ // they're attached to.
+ let (layer1, handle1) = {
+ let span = span::named("span1");
+ let filter: EnvFilter = "[span1]=debug".parse().expect("filter 1 should parse");
+ let (layer, handle) = layer::named("layer1")
+ .enter(span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![span.clone()]),
+ )
+ .exit(span)
+ .done()
+ .run_with_handle();
+ (layer.with_filter(filter), handle)
+ };
+
+ let (layer2, handle2) = {
+ let span = span::named("span2");
+ let filter: EnvFilter = "[span2]=info".parse().expect("filter 2 should parse");
+ let (layer, handle) = layer::named("layer2")
+ .enter(span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::INFO)
+ .in_scope(vec![span.clone()]),
+ )
+ .exit(span)
+ .done()
+ .run_with_handle();
+ (layer.with_filter(filter), handle)
+ };
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer1)
+ .with(layer2)
+ .set_default();
+
+ tracing::info_span!("span1").in_scope(|| {
+ tracing::debug!("hello from span 1");
+ tracing::trace!("not enabled");
+ });
+
+ tracing::info_span!("span2").in_scope(|| {
+ tracing::info!("hello from span 2");
+ tracing::debug!("not enabled");
+ });
+
+ handle1.assert_finished();
+ handle2.assert_finished();
+ }
+}
diff --git a/vendor/tracing-subscriber/tests/env_filter/per_layer.rs b/vendor/tracing-subscriber/tests/env_filter/per_layer.rs
new file mode 100644
index 000000000..8bf5698a4
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/env_filter/per_layer.rs
@@ -0,0 +1,305 @@
+//! Tests for using `EnvFilter` as a per-layer filter (rather than a global
+//! `Layer` filter).
+#![cfg(feature = "registry")]
+use super::*;
+
+#[test]
+fn level_filter_event() {
+ let filter: EnvFilter = "info".parse().expect("filter should parse");
+ let (layer, handle) = layer::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::ERROR))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "foo", "this should also be disabled");
+ tracing::warn!(target: "foo", "this should be enabled");
+ tracing::error!("this should be enabled too");
+
+ handle.assert_finished();
+}
+
+#[test]
+fn same_name_spans() {
+ let filter: EnvFilter = "[foo{bar}]=trace,[foo{baz}]=trace"
+ .parse()
+ .expect("filter should parse");
+ let (layer, handle) = layer::mock()
+ .new_span(
+ span::mock()
+ .named("foo")
+ .at_level(Level::TRACE)
+ .with_field(field::mock("bar")),
+ )
+ .new_span(
+ span::mock()
+ .named("foo")
+ .at_level(Level::TRACE)
+ .with_field(field::mock("baz")),
+ )
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace_span!("foo", bar = 1);
+ tracing::trace_span!("foo", baz = 1);
+
+ handle.assert_finished();
+}
+
+#[test]
+fn level_filter_event_with_target() {
+ let filter: EnvFilter = "info,stuff=debug".parse().expect("filter should parse");
+ let (layer, handle) = layer::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::DEBUG).with_target("stuff"))
+ .event(event::mock().at_level(Level::WARN).with_target("stuff"))
+ .event(event::mock().at_level(Level::ERROR))
+ .event(event::mock().at_level(Level::ERROR).with_target("stuff"))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "stuff", "this should be enabled");
+ tracing::debug!("but this shouldn't");
+ tracing::trace!(target: "stuff", "and neither should this");
+ tracing::warn!(target: "stuff", "this should be enabled");
+ tracing::error!("this should be enabled too");
+ tracing::error!(target: "stuff", "this should be enabled also");
+
+ handle.assert_finished();
+}
+
+#[test]
+fn level_filter_event_with_target_and_span() {
+ let filter: EnvFilter = "stuff[cool_span]=debug"
+ .parse()
+ .expect("filter should parse");
+
+ let cool_span = span::named("cool_span");
+ let (layer, handle) = layer::mock()
+ .enter(cool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![cool_span.clone()]),
+ )
+ .exit(cool_span)
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ {
+ let _span = tracing::info_span!(target: "stuff", "cool_span").entered();
+ tracing::debug!("this should be enabled");
+ }
+
+ tracing::debug!("should also be disabled");
+
+ {
+ let _span = tracing::info_span!("uncool_span").entered();
+ tracing::debug!("this should be disabled");
+ }
+
+ handle.assert_finished();
+}
+
+#[test]
+fn not_order_dependent() {
+ // this test reproduces tokio-rs/tracing#623
+
+ let filter: EnvFilter = "stuff=debug,info".parse().expect("filter should parse");
+ let (layer, finished) = layer::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::DEBUG).with_target("stuff"))
+ .event(event::mock().at_level(Level::WARN).with_target("stuff"))
+ .event(event::mock().at_level(Level::ERROR))
+ .event(event::mock().at_level(Level::ERROR).with_target("stuff"))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ tracing::debug!(target: "stuff", "this should be enabled");
+ tracing::debug!("but this shouldn't");
+ tracing::trace!(target: "stuff", "and neither should this");
+ tracing::warn!(target: "stuff", "this should be enabled");
+ tracing::error!("this should be enabled too");
+ tracing::error!(target: "stuff", "this should be enabled also");
+
+ finished.assert_finished();
+}
+
+#[test]
+fn add_directive_enables_event() {
+ // this test reproduces tokio-rs/tracing#591
+
+ // by default, use info level
+ let mut filter = EnvFilter::new(LevelFilter::INFO.to_string());
+
+ // overwrite with a more specific directive
+ filter = filter.add_directive("hello=trace".parse().expect("directive should parse"));
+
+ let (layer, finished) = layer::mock()
+ .event(event::mock().at_level(Level::INFO).with_target("hello"))
+ .event(event::mock().at_level(Level::TRACE).with_target("hello"))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::info!(target: "hello", "hello info");
+ tracing::trace!(target: "hello", "hello trace");
+
+ finished.assert_finished();
+}
+
+#[test]
+fn span_name_filter_is_dynamic() {
+ let filter: EnvFilter = "info,[cool_span]=debug"
+ .parse()
+ .expect("filter should parse");
+ let cool_span = span::named("cool_span");
+ let uncool_span = span::named("uncool_span");
+ let (layer, finished) = layer::mock()
+ .event(event::mock().at_level(Level::INFO))
+ .enter(cool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![cool_span.clone()]),
+ )
+ .enter(uncool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::WARN)
+ .in_scope(vec![uncool_span.clone()]),
+ )
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![uncool_span.clone()]),
+ )
+ .exit(uncool_span.clone())
+ .exit(cool_span)
+ .enter(uncool_span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::WARN)
+ .in_scope(vec![uncool_span.clone()]),
+ )
+ .event(
+ event::mock()
+ .at_level(Level::ERROR)
+ .in_scope(vec![uncool_span.clone()]),
+ )
+ .exit(uncool_span)
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ tracing::trace!("this should be disabled");
+ tracing::info!("this shouldn't be");
+ let cool_span = tracing::info_span!("cool_span");
+ let uncool_span = tracing::info_span!("uncool_span");
+
+ {
+ let _enter = cool_span.enter();
+ tracing::debug!("i'm a cool event");
+ tracing::trace!("i'm cool, but not cool enough");
+ let _enter2 = uncool_span.enter();
+ tracing::warn!("warning: extremely cool!");
+ tracing::debug!("i'm still cool");
+ }
+
+ {
+ let _enter = uncool_span.enter();
+ tracing::warn!("warning: not that cool");
+ tracing::trace!("im not cool enough");
+ tracing::error!("uncool error");
+ }
+
+ finished.assert_finished();
+}
+
+#[test]
+fn multiple_dynamic_filters() {
+ // Test that multiple dynamic (span) filters only apply to the layers
+ // they're attached to.
+ let (layer1, handle1) = {
+ let span = span::named("span1");
+ let filter: EnvFilter = "[span1]=debug".parse().expect("filter 1 should parse");
+ let (layer, handle) = layer::named("layer1")
+ .enter(span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::DEBUG)
+ .in_scope(vec![span.clone()]),
+ )
+ .exit(span)
+ .done()
+ .run_with_handle();
+ (layer.with_filter(filter), handle)
+ };
+
+ let (layer2, handle2) = {
+ let span = span::named("span2");
+ let filter: EnvFilter = "[span2]=info".parse().expect("filter 2 should parse");
+ let (layer, handle) = layer::named("layer2")
+ .enter(span.clone())
+ .event(
+ event::mock()
+ .at_level(Level::INFO)
+ .in_scope(vec![span.clone()]),
+ )
+ .exit(span)
+ .done()
+ .run_with_handle();
+ (layer.with_filter(filter), handle)
+ };
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer1)
+ .with(layer2)
+ .set_default();
+
+ tracing::info_span!("span1").in_scope(|| {
+ tracing::debug!("hello from span 1");
+ tracing::trace!("not enabled");
+ });
+
+ tracing::info_span!("span2").in_scope(|| {
+ tracing::info!("hello from span 2");
+ tracing::debug!("not enabled");
+ });
+
+ handle1.assert_finished();
+ handle2.assert_finished();
+}
diff --git a/vendor/tracing-subscriber/tests/event_enabling.rs b/vendor/tracing-subscriber/tests/event_enabling.rs
new file mode 100644
index 000000000..8f67cfcba
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/event_enabling.rs
@@ -0,0 +1,81 @@
+#![cfg(feature = "registry")]
+
+use std::sync::{Arc, Mutex};
+use tracing::{subscriber::with_default, Event, Metadata, Subscriber};
+use tracing_subscriber::{layer::Context, prelude::*, registry, Layer};
+
+struct TrackingLayer {
+ enabled: bool,
+ event_enabled_count: Arc<Mutex<usize>>,
+ event_enabled: bool,
+ on_event_count: Arc<Mutex<usize>>,
+}
+
+impl<C> Layer<C> for TrackingLayer
+where
+ C: Subscriber + Send + Sync + 'static,
+{
+ fn enabled(&self, _metadata: &Metadata<'_>, _ctx: Context<'_, C>) -> bool {
+ self.enabled
+ }
+
+ fn event_enabled(&self, _event: &Event<'_>, _ctx: Context<'_, C>) -> bool {
+ *self.event_enabled_count.lock().unwrap() += 1;
+ self.event_enabled
+ }
+
+ fn on_event(&self, _event: &Event<'_>, _ctx: Context<'_, C>) {
+ *self.on_event_count.lock().unwrap() += 1;
+ }
+}
+
+#[test]
+fn event_enabled_is_only_called_once() {
+ let event_enabled_count = Arc::new(Mutex::default());
+ let count = event_enabled_count.clone();
+ let subscriber = registry().with(TrackingLayer {
+ enabled: true,
+ event_enabled_count,
+ event_enabled: true,
+ on_event_count: Arc::new(Mutex::default()),
+ });
+ with_default(subscriber, || {
+ tracing::error!("hiya!");
+ });
+
+ assert_eq!(1, *count.lock().unwrap());
+}
+
+#[test]
+fn event_enabled_not_called_when_not_enabled() {
+ let event_enabled_count = Arc::new(Mutex::default());
+ let count = event_enabled_count.clone();
+ let subscriber = registry().with(TrackingLayer {
+ enabled: false,
+ event_enabled_count,
+ event_enabled: true,
+ on_event_count: Arc::new(Mutex::default()),
+ });
+ with_default(subscriber, || {
+ tracing::error!("hiya!");
+ });
+
+ assert_eq!(0, *count.lock().unwrap());
+}
+
+#[test]
+fn event_disabled_does_disable_event() {
+ let on_event_count = Arc::new(Mutex::default());
+ let count = on_event_count.clone();
+ let subscriber = registry().with(TrackingLayer {
+ enabled: true,
+ event_enabled_count: Arc::new(Mutex::default()),
+ event_enabled: false,
+ on_event_count,
+ });
+ with_default(subscriber, || {
+ tracing::error!("hiya!");
+ });
+
+ assert_eq!(0, *count.lock().unwrap());
+}
diff --git a/vendor/tracing-subscriber-0.3.3/tests/field_filter.rs b/vendor/tracing-subscriber/tests/field_filter.rs
index 12b4053b6..f14a0626d 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/field_filter.rs
+++ b/vendor/tracing-subscriber/tests/field_filter.rs
@@ -1,7 +1,7 @@
#![cfg(feature = "env-filter")]
-mod support;
-use self::support::*;
+
use tracing::{self, subscriber::with_default, Level};
+use tracing_mock::*;
use tracing_subscriber::{filter::EnvFilter, prelude::*};
#[test]
diff --git a/vendor/tracing-subscriber-0.3.3/tests/filter_log.rs b/vendor/tracing-subscriber/tests/filter_log.rs
index 28e742501..8d57ed600 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/filter_log.rs
+++ b/vendor/tracing-subscriber/tests/filter_log.rs
@@ -1,7 +1,7 @@
#![cfg(all(feature = "env-filter", feature = "tracing-log"))]
-mod support;
-use self::support::*;
+
use tracing::{self, Level};
+use tracing_mock::*;
use tracing_subscriber::{filter::EnvFilter, prelude::*};
mod my_module {
diff --git a/vendor/tracing-subscriber-0.3.3/tests/fmt_max_level_hint.rs b/vendor/tracing-subscriber/tests/fmt_max_level_hint.rs
index 57a0f6e3f..57a0f6e3f 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/fmt_max_level_hint.rs
+++ b/vendor/tracing-subscriber/tests/fmt_max_level_hint.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/hinted_layer_filters_dont_break_other_layers.rs b/vendor/tracing-subscriber/tests/hinted_layer_filters_dont_break_other_layers.rs
index 897dae282..897dae282 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/hinted_layer_filters_dont_break_other_layers.rs
+++ b/vendor/tracing-subscriber/tests/hinted_layer_filters_dont_break_other_layers.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/layer_filter_interests_are_cached.rs b/vendor/tracing-subscriber/tests/layer_filter_interests_are_cached.rs
index d89d3bf17..d89d3bf17 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/layer_filter_interests_are_cached.rs
+++ b/vendor/tracing-subscriber/tests/layer_filter_interests_are_cached.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/boxed.rs b/vendor/tracing-subscriber/tests/layer_filters/boxed.rs
index 0fe37188e..0fe37188e 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/boxed.rs
+++ b/vendor/tracing-subscriber/tests/layer_filters/boxed.rs
diff --git a/vendor/tracing-subscriber/tests/layer_filters/combinators.rs b/vendor/tracing-subscriber/tests/layer_filters/combinators.rs
new file mode 100644
index 000000000..6052a2d00
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/layer_filters/combinators.rs
@@ -0,0 +1,42 @@
+use super::*;
+use tracing_subscriber::{
+ filter::{filter_fn, FilterExt, LevelFilter},
+ prelude::*,
+};
+
+#[test]
+fn and() {
+ let (layer, handle) = layer::mock()
+ .event(
+ event::msg("a very interesting event")
+ .at_level(tracing::Level::INFO)
+ .with_target("interesting_target"),
+ )
+ .done()
+ .run_with_handle();
+
+ // Enables spans and events with targets starting with `interesting_target`:
+ let target_filter = filter::filter_fn(|meta| meta.target().starts_with("interesting_target"));
+
+ // Enables spans and events with levels `INFO` and below:
+ let level_filter = LevelFilter::INFO;
+
+ // Combine the two filters together, returning a filter that only enables
+ // spans and events that *both* filters will enable:
+ let filter = target_filter.and(level_filter);
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(layer.with_filter(filter))
+ .set_default();
+
+ // This event will *not* be enabled:
+ tracing::info!("an event with an uninteresting target");
+
+ // This event *will* be enabled:
+ tracing::info!(target: "interesting_target", "a very interesting event");
+
+ // This event will *not* be enabled:
+ tracing::debug!(target: "interesting_target", "interesting debug event...");
+
+ handle.assert_finished();
+}
diff --git a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/downcast_raw.rs b/vendor/tracing-subscriber/tests/layer_filters/downcast_raw.rs
index b5f7e35ce..b5f7e35ce 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/downcast_raw.rs
+++ b/vendor/tracing-subscriber/tests/layer_filters/downcast_raw.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/filter_scopes.rs b/vendor/tracing-subscriber/tests/layer_filters/filter_scopes.rs
index 7fd7d843b..7fd7d843b 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/filter_scopes.rs
+++ b/vendor/tracing-subscriber/tests/layer_filters/filter_scopes.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/main.rs b/vendor/tracing-subscriber/tests/layer_filters/main.rs
index 2359584d7..10f06c24c 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/main.rs
+++ b/vendor/tracing-subscriber/tests/layer_filters/main.rs
@@ -5,11 +5,13 @@ use self::support::*;
mod boxed;
mod downcast_raw;
mod filter_scopes;
+mod per_event;
mod targets;
mod trees;
+mod vec;
use tracing::{level_filters::LevelFilter, Level};
-use tracing_subscriber::{filter, prelude::*};
+use tracing_subscriber::{filter, prelude::*, Layer};
#[test]
fn basic_layer_filters() {
diff --git a/vendor/tracing-subscriber/tests/layer_filters/per_event.rs b/vendor/tracing-subscriber/tests/layer_filters/per_event.rs
new file mode 100644
index 000000000..9c785f9a2
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/layer_filters/per_event.rs
@@ -0,0 +1,61 @@
+use crate::support::*;
+use tracing::Level;
+use tracing_subscriber::{field::Visit, layer::Filter, prelude::*};
+
+struct FilterEvent;
+
+impl<S> Filter<S> for FilterEvent {
+ fn enabled(
+ &self,
+ _meta: &tracing::Metadata<'_>,
+ _cx: &tracing_subscriber::layer::Context<'_, S>,
+ ) -> bool {
+ true
+ }
+
+ fn event_enabled(
+ &self,
+ event: &tracing::Event<'_>,
+ _cx: &tracing_subscriber::layer::Context<'_, S>,
+ ) -> bool {
+ struct ShouldEnable(bool);
+ impl Visit for ShouldEnable {
+ fn record_bool(&mut self, field: &tracing_core::Field, value: bool) {
+ if field.name() == "enable" {
+ self.0 = value;
+ }
+ }
+
+ fn record_debug(
+ &mut self,
+ _field: &tracing_core::Field,
+ _value: &dyn core::fmt::Debug,
+ ) {
+ }
+ }
+ let mut should_enable = ShouldEnable(false);
+ event.record(&mut should_enable);
+ should_enable.0
+ }
+}
+
+#[test]
+fn per_subscriber_event_field_filtering() {
+ let (expect, handle) = layer::mock()
+ .event(event::mock().at_level(Level::TRACE))
+ .event(event::mock().at_level(Level::INFO))
+ .done()
+ .run_with_handle();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(expect.with_filter(FilterEvent))
+ .set_default();
+
+ tracing::trace!(enable = true, "hello trace");
+ tracing::debug!("hello debug");
+ tracing::info!(enable = true, "hello info");
+ tracing::warn!(enable = false, "hello warn");
+ tracing::error!("hello error");
+
+ handle.assert_finished();
+}
diff --git a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/targets.rs b/vendor/tracing-subscriber/tests/layer_filters/targets.rs
index c8133044b..c8133044b 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/targets.rs
+++ b/vendor/tracing-subscriber/tests/layer_filters/targets.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/trees.rs b/vendor/tracing-subscriber/tests/layer_filters/trees.rs
index 18cdd8ccc..18cdd8ccc 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/layer_filters/trees.rs
+++ b/vendor/tracing-subscriber/tests/layer_filters/trees.rs
diff --git a/vendor/tracing-subscriber/tests/layer_filters/vec.rs b/vendor/tracing-subscriber/tests/layer_filters/vec.rs
new file mode 100644
index 000000000..87244e4ab
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/layer_filters/vec.rs
@@ -0,0 +1,120 @@
+use super::*;
+use tracing::Subscriber;
+
+#[test]
+fn with_filters_unboxed() {
+ let (trace_layer, trace_handle) = layer::named("trace")
+ .event(event::mock().at_level(Level::TRACE))
+ .event(event::mock().at_level(Level::DEBUG))
+ .event(event::mock().at_level(Level::INFO))
+ .done()
+ .run_with_handle();
+ let trace_layer = trace_layer.with_filter(LevelFilter::TRACE);
+
+ let (debug_layer, debug_handle) = layer::named("debug")
+ .event(event::mock().at_level(Level::DEBUG))
+ .event(event::mock().at_level(Level::INFO))
+ .done()
+ .run_with_handle();
+ let debug_layer = debug_layer.with_filter(LevelFilter::DEBUG);
+
+ let (info_layer, info_handle) = layer::named("info")
+ .event(event::mock().at_level(Level::INFO))
+ .done()
+ .run_with_handle();
+ let info_layer = info_layer.with_filter(LevelFilter::INFO);
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(vec![trace_layer, debug_layer, info_layer])
+ .set_default();
+
+ tracing::trace!("hello trace");
+ tracing::debug!("hello debug");
+ tracing::info!("hello info");
+
+ trace_handle.assert_finished();
+ debug_handle.assert_finished();
+ info_handle.assert_finished();
+}
+
+#[test]
+fn with_filters_boxed() {
+ let (unfiltered_layer, unfiltered_handle) = layer::named("unfiltered")
+ .event(event::mock().at_level(Level::TRACE))
+ .event(event::mock().at_level(Level::DEBUG))
+ .event(event::mock().at_level(Level::INFO))
+ .done()
+ .run_with_handle();
+ let unfiltered_layer = unfiltered_layer.boxed();
+
+ let (debug_layer, debug_handle) = layer::named("debug")
+ .event(event::mock().at_level(Level::DEBUG))
+ .event(event::mock().at_level(Level::INFO))
+ .done()
+ .run_with_handle();
+ let debug_layer = debug_layer.with_filter(LevelFilter::DEBUG).boxed();
+
+ let (target_layer, target_handle) = layer::named("target")
+ .event(event::mock().at_level(Level::INFO))
+ .done()
+ .run_with_handle();
+ let target_layer = target_layer
+ .with_filter(filter::filter_fn(|meta| meta.target() == "my_target"))
+ .boxed();
+
+ let _subscriber = tracing_subscriber::registry()
+ .with(vec![unfiltered_layer, debug_layer, target_layer])
+ .set_default();
+
+ tracing::trace!("hello trace");
+ tracing::debug!("hello debug");
+ tracing::info!(target: "my_target", "hello my target");
+
+ unfiltered_handle.assert_finished();
+ debug_handle.assert_finished();
+ target_handle.assert_finished();
+}
+
+#[test]
+fn mixed_max_level_hint() {
+ let unfiltered = layer::named("unfiltered").run().boxed();
+ let info = layer::named("info")
+ .run()
+ .with_filter(LevelFilter::INFO)
+ .boxed();
+ let debug = layer::named("debug")
+ .run()
+ .with_filter(LevelFilter::DEBUG)
+ .boxed();
+
+ let subscriber = tracing_subscriber::registry().with(vec![unfiltered, info, debug]);
+
+ assert_eq!(subscriber.max_level_hint(), None);
+}
+
+#[test]
+fn all_filtered_max_level_hint() {
+ let warn = layer::named("warn")
+ .run()
+ .with_filter(LevelFilter::WARN)
+ .boxed();
+ let info = layer::named("info")
+ .run()
+ .with_filter(LevelFilter::INFO)
+ .boxed();
+ let debug = layer::named("debug")
+ .run()
+ .with_filter(LevelFilter::DEBUG)
+ .boxed();
+
+ let subscriber = tracing_subscriber::registry().with(vec![warn, info, debug]);
+
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::DEBUG));
+}
+
+#[test]
+fn empty_vec() {
+ // Just a None means everything is off
+ let subscriber = tracing_subscriber::registry().with(Vec::<ExpectLayer>::new());
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::OFF));
+}
diff --git a/vendor/tracing-subscriber-0.3.3/tests/multiple_layer_filter_interests_cached.rs b/vendor/tracing-subscriber/tests/multiple_layer_filter_interests_cached.rs
index 5c25e7f03..5c25e7f03 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/multiple_layer_filter_interests_cached.rs
+++ b/vendor/tracing-subscriber/tests/multiple_layer_filter_interests_cached.rs
diff --git a/vendor/tracing-subscriber/tests/option.rs b/vendor/tracing-subscriber/tests/option.rs
new file mode 100644
index 000000000..c87519c30
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/option.rs
@@ -0,0 +1,262 @@
+#![cfg(feature = "registry")]
+use tracing_core::{subscriber::Interest, LevelFilter, Metadata, Subscriber};
+use tracing_subscriber::{layer, prelude::*};
+
+// A basic layer that returns its inner for `max_level_hint`
+#[derive(Debug)]
+struct BasicLayer(Option<LevelFilter>);
+impl<S: Subscriber> tracing_subscriber::Layer<S> for BasicLayer {
+ fn register_callsite(&self, _m: &Metadata<'_>) -> Interest {
+ Interest::sometimes()
+ }
+
+ fn enabled(&self, _m: &Metadata<'_>, _: layer::Context<'_, S>) -> bool {
+ true
+ }
+
+ fn max_level_hint(&self) -> Option<LevelFilter> {
+ self.0
+ }
+}
+
+// This test is just used to compare to the tests below
+#[test]
+fn just_layer() {
+ let subscriber = tracing_subscriber::registry().with(LevelFilter::INFO);
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::INFO));
+}
+
+#[test]
+fn subscriber_and_option_some_layer() {
+ let subscriber = tracing_subscriber::registry()
+ .with(LevelFilter::INFO)
+ .with(Some(LevelFilter::DEBUG));
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::DEBUG));
+}
+
+#[test]
+fn subscriber_and_option_none_layer() {
+ // None means the other layer takes control
+ let subscriber = tracing_subscriber::registry()
+ .with(LevelFilter::ERROR)
+ .with(None::<LevelFilter>);
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::ERROR));
+}
+
+#[test]
+fn just_option_some_layer() {
+ // Just a None means everything is off
+ let subscriber = tracing_subscriber::registry().with(None::<LevelFilter>);
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::OFF));
+}
+
+/// Tests that the logic tested in `doesnt_override_none` works through the reload subscriber
+#[test]
+fn just_option_none_layer() {
+ let subscriber = tracing_subscriber::registry().with(Some(LevelFilter::ERROR));
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::ERROR));
+}
+
+// Test that the `None` max level hint only applies if its the only layer
+#[test]
+fn none_outside_doesnt_override_max_level() {
+ // None means the other layer takes control
+ let subscriber = tracing_subscriber::registry()
+ .with(BasicLayer(None))
+ .with(None::<LevelFilter>);
+ assert_eq!(
+ subscriber.max_level_hint(),
+ None,
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // The `None`-returning layer still wins
+ let subscriber = tracing_subscriber::registry()
+ .with(BasicLayer(None))
+ .with(Some(LevelFilter::ERROR));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::ERROR),
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // Check that we aren't doing anything truly wrong
+ let subscriber = tracing_subscriber::registry()
+ .with(BasicLayer(Some(LevelFilter::DEBUG)))
+ .with(None::<LevelFilter>);
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::DEBUG),
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // Test that per-subscriber filters aren't affected
+
+ // One layer is None so it "wins"
+ let subscriber = tracing_subscriber::registry()
+ .with(BasicLayer(None))
+ .with(None::<LevelFilter>.with_filter(LevelFilter::DEBUG));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ None,
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // The max-levels wins
+ let subscriber = tracing_subscriber::registry()
+ .with(BasicLayer(Some(LevelFilter::INFO)))
+ .with(None::<LevelFilter>.with_filter(LevelFilter::DEBUG));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::DEBUG),
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // Test filter on the other layer
+ let subscriber = tracing_subscriber::registry()
+ .with(BasicLayer(Some(LevelFilter::INFO)).with_filter(LevelFilter::DEBUG))
+ .with(None::<LevelFilter>);
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::DEBUG),
+ "\n stack: {:#?}",
+ subscriber
+ );
+ let subscriber = tracing_subscriber::registry()
+ .with(BasicLayer(None).with_filter(LevelFilter::DEBUG))
+ .with(None::<LevelFilter>);
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::DEBUG),
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // The `OFF` from `None` over overridden.
+ let subscriber = tracing_subscriber::registry()
+ .with(BasicLayer(Some(LevelFilter::INFO)))
+ .with(None::<LevelFilter>);
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::INFO),
+ "\n stack: {:#?}",
+ subscriber
+ );
+}
+
+// Test that the `None` max level hint only applies if its the only layer
+#[test]
+fn none_inside_doesnt_override_max_level() {
+ // None means the other layer takes control
+ let subscriber = tracing_subscriber::registry()
+ .with(None::<LevelFilter>)
+ .with(BasicLayer(None));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ None,
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // The `None`-returning layer still wins
+ let subscriber = tracing_subscriber::registry()
+ .with(Some(LevelFilter::ERROR))
+ .with(BasicLayer(None));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::ERROR),
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // Check that we aren't doing anything truly wrong
+ let subscriber = tracing_subscriber::registry()
+ .with(None::<LevelFilter>)
+ .with(BasicLayer(Some(LevelFilter::DEBUG)));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::DEBUG),
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // Test that per-subscriber filters aren't affected
+
+ // One layer is None so it "wins"
+ let subscriber = tracing_subscriber::registry()
+ .with(None::<LevelFilter>.with_filter(LevelFilter::DEBUG))
+ .with(BasicLayer(None));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ None,
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // The max-levels wins
+ let subscriber = tracing_subscriber::registry()
+ .with(None::<LevelFilter>.with_filter(LevelFilter::DEBUG))
+ .with(BasicLayer(Some(LevelFilter::INFO)));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::DEBUG),
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // Test filter on the other layer
+ let subscriber = tracing_subscriber::registry()
+ .with(None::<LevelFilter>)
+ .with(BasicLayer(Some(LevelFilter::INFO)).with_filter(LevelFilter::DEBUG));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::DEBUG),
+ "\n stack: {:#?}",
+ subscriber
+ );
+ let subscriber = tracing_subscriber::registry()
+ .with(None::<LevelFilter>)
+ .with(BasicLayer(None).with_filter(LevelFilter::DEBUG));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::DEBUG),
+ "\n stack: {:#?}",
+ subscriber
+ );
+
+ // The `OFF` from `None` over overridden.
+ let subscriber = tracing_subscriber::registry()
+ .with(None::<LevelFilter>)
+ .with(BasicLayer(Some(LevelFilter::INFO)));
+ assert_eq!(
+ subscriber.max_level_hint(),
+ Some(LevelFilter::INFO),
+ "\n stack: {:#?}",
+ subscriber
+ );
+}
+
+/// Tests that the logic tested in `doesnt_override_none` works through the reload layer
+#[test]
+fn reload_works_with_none() {
+ let (layer1, handle1) = tracing_subscriber::reload::Layer::new(None::<BasicLayer>);
+ let (layer2, _handle2) = tracing_subscriber::reload::Layer::new(None::<BasicLayer>);
+
+ let subscriber = tracing_subscriber::registry().with(layer1).with(layer2);
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::OFF));
+
+ // reloading one should pass through correctly.
+ handle1.reload(Some(BasicLayer(None))).unwrap();
+ assert_eq!(subscriber.max_level_hint(), None);
+
+ // Check pass-through of an actual level as well
+ handle1
+ .reload(Some(BasicLayer(Some(LevelFilter::DEBUG))))
+ .unwrap();
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::DEBUG));
+}
diff --git a/vendor/tracing-subscriber-0.3.3/tests/registry_max_level_hint.rs b/vendor/tracing-subscriber/tests/registry_max_level_hint.rs
index f94c8a1fb..f94c8a1fb 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/registry_max_level_hint.rs
+++ b/vendor/tracing-subscriber/tests/registry_max_level_hint.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/registry_with_subscriber.rs b/vendor/tracing-subscriber/tests/registry_with_subscriber.rs
index 3f8d99b1d..50d2f551d 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/registry_with_subscriber.rs
+++ b/vendor/tracing-subscriber/tests/registry_with_subscriber.rs
@@ -4,7 +4,7 @@ use tracing_subscriber::prelude::*;
#[tokio::test]
async fn future_with_subscriber() {
- let _default = tracing_subscriber::registry().init();
+ tracing_subscriber::registry().init();
let span = tracing::info_span!("foo");
let _e = span.enter();
let span = tracing::info_span!("bar");
diff --git a/vendor/tracing-subscriber/tests/reload.rs b/vendor/tracing-subscriber/tests/reload.rs
new file mode 100644
index 000000000..28662e2e6
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/reload.rs
@@ -0,0 +1,155 @@
+#![cfg(feature = "registry")]
+use std::sync::atomic::{AtomicUsize, Ordering};
+use tracing_core::{
+ span::{Attributes, Id, Record},
+ subscriber::Interest,
+ Event, LevelFilter, Metadata, Subscriber,
+};
+use tracing_subscriber::{layer, prelude::*, reload::*};
+
+pub struct NopSubscriber;
+fn event() {
+ tracing::info!("my event");
+}
+
+impl Subscriber for NopSubscriber {
+ fn register_callsite(&self, _: &'static Metadata<'static>) -> Interest {
+ Interest::never()
+ }
+
+ fn enabled(&self, _: &Metadata<'_>) -> bool {
+ false
+ }
+
+ fn new_span(&self, _: &Attributes<'_>) -> Id {
+ Id::from_u64(1)
+ }
+
+ fn record(&self, _: &Id, _: &Record<'_>) {}
+ fn record_follows_from(&self, _: &Id, _: &Id) {}
+ fn event(&self, _: &Event<'_>) {}
+ fn enter(&self, _: &Id) {}
+ fn exit(&self, _: &Id) {}
+}
+
+#[test]
+fn reload_handle() {
+ static FILTER1_CALLS: AtomicUsize = AtomicUsize::new(0);
+ static FILTER2_CALLS: AtomicUsize = AtomicUsize::new(0);
+
+ enum Filter {
+ One,
+ Two,
+ }
+
+ impl<S: Subscriber> tracing_subscriber::Layer<S> for Filter {
+ fn register_callsite(&self, m: &Metadata<'_>) -> Interest {
+ println!("REGISTER: {:?}", m);
+ Interest::sometimes()
+ }
+
+ fn enabled(&self, m: &Metadata<'_>, _: layer::Context<'_, S>) -> bool {
+ println!("ENABLED: {:?}", m);
+ match self {
+ Filter::One => FILTER1_CALLS.fetch_add(1, Ordering::SeqCst),
+ Filter::Two => FILTER2_CALLS.fetch_add(1, Ordering::SeqCst),
+ };
+ true
+ }
+
+ fn max_level_hint(&self) -> Option<LevelFilter> {
+ match self {
+ Filter::One => Some(LevelFilter::INFO),
+ Filter::Two => Some(LevelFilter::DEBUG),
+ }
+ }
+ }
+
+ let (layer, handle) = Layer::new(Filter::One);
+
+ let subscriber = tracing_core::dispatcher::Dispatch::new(layer.with_subscriber(NopSubscriber));
+
+ tracing_core::dispatcher::with_default(&subscriber, || {
+ assert_eq!(FILTER1_CALLS.load(Ordering::SeqCst), 0);
+ assert_eq!(FILTER2_CALLS.load(Ordering::SeqCst), 0);
+
+ event();
+
+ assert_eq!(FILTER1_CALLS.load(Ordering::SeqCst), 1);
+ assert_eq!(FILTER2_CALLS.load(Ordering::SeqCst), 0);
+
+ assert_eq!(LevelFilter::current(), LevelFilter::INFO);
+ handle.reload(Filter::Two).expect("should reload");
+ assert_eq!(LevelFilter::current(), LevelFilter::DEBUG);
+
+ event();
+
+ assert_eq!(FILTER1_CALLS.load(Ordering::SeqCst), 1);
+ assert_eq!(FILTER2_CALLS.load(Ordering::SeqCst), 1);
+ })
+}
+
+#[test]
+fn reload_filter() {
+ struct NopLayer;
+ impl<S: Subscriber> tracing_subscriber::Layer<S> for NopLayer {
+ fn register_callsite(&self, _m: &Metadata<'_>) -> Interest {
+ Interest::sometimes()
+ }
+
+ fn enabled(&self, _m: &Metadata<'_>, _: layer::Context<'_, S>) -> bool {
+ true
+ }
+ }
+
+ static FILTER1_CALLS: AtomicUsize = AtomicUsize::new(0);
+ static FILTER2_CALLS: AtomicUsize = AtomicUsize::new(0);
+
+ enum Filter {
+ One,
+ Two,
+ }
+
+ impl<S: Subscriber> tracing_subscriber::layer::Filter<S> for Filter {
+ fn enabled(&self, m: &Metadata<'_>, _: &layer::Context<'_, S>) -> bool {
+ println!("ENABLED: {:?}", m);
+ match self {
+ Filter::One => FILTER1_CALLS.fetch_add(1, Ordering::SeqCst),
+ Filter::Two => FILTER2_CALLS.fetch_add(1, Ordering::SeqCst),
+ };
+ true
+ }
+
+ fn max_level_hint(&self) -> Option<LevelFilter> {
+ match self {
+ Filter::One => Some(LevelFilter::INFO),
+ Filter::Two => Some(LevelFilter::DEBUG),
+ }
+ }
+ }
+
+ let (filter, handle) = Layer::new(Filter::One);
+
+ let dispatcher = tracing_core::Dispatch::new(
+ tracing_subscriber::registry().with(NopLayer.with_filter(filter)),
+ );
+
+ tracing_core::dispatcher::with_default(&dispatcher, || {
+ assert_eq!(FILTER1_CALLS.load(Ordering::SeqCst), 0);
+ assert_eq!(FILTER2_CALLS.load(Ordering::SeqCst), 0);
+
+ event();
+
+ assert_eq!(FILTER1_CALLS.load(Ordering::SeqCst), 1);
+ assert_eq!(FILTER2_CALLS.load(Ordering::SeqCst), 0);
+
+ assert_eq!(LevelFilter::current(), LevelFilter::INFO);
+ handle.reload(Filter::Two).expect("should reload");
+ assert_eq!(LevelFilter::current(), LevelFilter::DEBUG);
+
+ event();
+
+ assert_eq!(FILTER1_CALLS.load(Ordering::SeqCst), 1);
+ assert_eq!(FILTER2_CALLS.load(Ordering::SeqCst), 1);
+ })
+}
diff --git a/vendor/tracing-subscriber-0.3.3/tests/same_len_filters.rs b/vendor/tracing-subscriber/tests/same_len_filters.rs
index b525ea6fd..879e578d7 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/same_len_filters.rs
+++ b/vendor/tracing-subscriber/tests/same_len_filters.rs
@@ -1,9 +1,9 @@
// These tests include field filters with no targets, so they have to go in a
// separate file.
#![cfg(feature = "env-filter")]
-mod support;
-use self::support::*;
+
use tracing::{self, subscriber::with_default, Level};
+use tracing_mock::*;
use tracing_subscriber::{filter::EnvFilter, prelude::*};
#[test]
diff --git a/vendor/tracing-subscriber-0.3.3/tests/support.rs b/vendor/tracing-subscriber/tests/support.rs
index 848ebdc63..50e0e6669 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/support.rs
+++ b/vendor/tracing-subscriber/tests/support.rs
@@ -1,20 +1,15 @@
#![allow(missing_docs, dead_code)]
-pub use self::support::{event, field, span, subscriber};
-// This has to have the same name as the module in `tracing`.
-// path attribute requires referenced module to have same name so allow module inception here
-#[allow(clippy::module_inception)]
-#[path = "../../tracing/tests/support/mod.rs"]
-mod support;
-
-use self::{
- event::MockEvent,
- span::{MockSpan, NewSpan},
- subscriber::{Expect, MockHandle},
-};
+pub use tracing_mock::{event, field, span, subscriber};
+
use tracing_core::{
span::{Attributes, Id, Record},
Event, Subscriber,
};
+use tracing_mock::{
+ event::MockEvent,
+ span::{MockSpan, NewSpan},
+ subscriber::{Expect, MockHandle},
+};
use tracing_subscriber::{
layer::{Context, Layer},
registry::{LookupSpan, SpanRef},
diff --git a/vendor/tracing-subscriber-0.3.3/tests/unhinted_layer_filters_dont_break_other_layers.rs b/vendor/tracing-subscriber/tests/unhinted_layer_filters_dont_break_other_layers.rs
index 9fa5c6bd4..9fa5c6bd4 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/unhinted_layer_filters_dont_break_other_layers.rs
+++ b/vendor/tracing-subscriber/tests/unhinted_layer_filters_dont_break_other_layers.rs
diff --git a/vendor/tracing-subscriber-0.3.3/tests/utils.rs b/vendor/tracing-subscriber/tests/utils.rs
index ff025a2a2..e95868d5e 100644
--- a/vendor/tracing-subscriber-0.3.3/tests/utils.rs
+++ b/vendor/tracing-subscriber/tests/utils.rs
@@ -1,6 +1,6 @@
#![cfg(feature = "std")]
-mod support;
-use self::support::*;
+
+use tracing_mock::*;
use tracing_subscriber::prelude::*;
#[test]
diff --git a/vendor/tracing-subscriber/tests/vec.rs b/vendor/tracing-subscriber/tests/vec.rs
new file mode 100644
index 000000000..92abf0bff
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/vec.rs
@@ -0,0 +1,19 @@
+#![cfg(feature = "registry")]
+use tracing::level_filters::LevelFilter;
+use tracing::Subscriber;
+use tracing_subscriber::prelude::*;
+
+#[test]
+fn just_empty_vec() {
+ // Just a None means everything is off
+ let subscriber = tracing_subscriber::registry().with(Vec::<LevelFilter>::new());
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::OFF));
+}
+
+#[test]
+fn layer_and_empty_vec() {
+ let subscriber = tracing_subscriber::registry()
+ .with(LevelFilter::INFO)
+ .with(Vec::<LevelFilter>::new());
+ assert_eq!(subscriber.max_level_hint(), Some(LevelFilter::INFO));
+}
diff --git a/vendor/tracing-subscriber/tests/vec_subscriber_filter_interests_cached.rs b/vendor/tracing-subscriber/tests/vec_subscriber_filter_interests_cached.rs
new file mode 100644
index 000000000..10467cb7d
--- /dev/null
+++ b/vendor/tracing-subscriber/tests/vec_subscriber_filter_interests_cached.rs
@@ -0,0 +1,117 @@
+#![cfg(feature = "registry")]
+mod support;
+use self::support::*;
+
+use std::{
+ collections::HashMap,
+ sync::{Arc, Mutex},
+};
+use tracing::{Level, Subscriber};
+use tracing_subscriber::{filter, prelude::*};
+
+#[test]
+fn vec_layer_filter_interests_are_cached() {
+ let mk_filtered = |level: Level, subscriber: ExpectLayer| {
+ let seen = Arc::new(Mutex::new(HashMap::new()));
+ let filter = filter::filter_fn({
+ let seen = seen.clone();
+ move |meta| {
+ *seen.lock().unwrap().entry(*meta.level()).or_insert(0usize) += 1;
+ meta.level() <= &level
+ }
+ });
+ (subscriber.with_filter(filter).boxed(), seen)
+ };
+
+ // This layer will return Interest::always for INFO and lower.
+ let (info_layer, info_handle) = layer::named("info")
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::ERROR))
+ .event(event::mock().at_level(Level::INFO))
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::ERROR))
+ .done()
+ .run_with_handle();
+ let (info_layer, seen_info) = mk_filtered(Level::INFO, info_layer);
+
+ // This layer will return Interest::always for WARN and lower.
+ let (warn_layer, warn_handle) = layer::named("warn")
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::ERROR))
+ .event(event::mock().at_level(Level::WARN))
+ .event(event::mock().at_level(Level::ERROR))
+ .done()
+ .run_with_handle();
+ let (warn_layer, seen_warn) = mk_filtered(Level::WARN, warn_layer);
+
+ let subscriber = tracing_subscriber::registry().with(vec![warn_layer, info_layer]);
+ assert!(subscriber.max_level_hint().is_none());
+
+ let _subscriber = subscriber.set_default();
+
+ fn events() {
+ tracing::trace!("hello trace");
+ tracing::debug!("hello debug");
+ tracing::info!("hello info");
+ tracing::warn!("hello warn");
+ tracing::error!("hello error");
+ }
+
+ events();
+ {
+ let lock = seen_info.lock().unwrap();
+ for (&level, &count) in lock.iter() {
+ if level == Level::INFO {
+ continue;
+ }
+ assert_eq!(
+ count, 1,
+ "level {:?} should have been seen 1 time by the INFO subscriber (after first set of events)",
+ level
+ );
+ }
+
+ let lock = seen_warn.lock().unwrap();
+ for (&level, &count) in lock.iter() {
+ if level == Level::INFO {
+ continue;
+ }
+ assert_eq!(
+ count, 1,
+ "level {:?} should have been seen 1 time by the WARN subscriber (after first set of events)",
+ level
+ );
+ }
+ }
+
+ events();
+ {
+ let lock = seen_info.lock().unwrap();
+ for (&level, &count) in lock.iter() {
+ if level == Level::INFO {
+ continue;
+ }
+ assert_eq!(
+ count, 1,
+ "level {:?} should have been seen 1 time by the INFO subscriber (after second set of events)",
+ level
+ );
+ }
+
+ let lock = seen_warn.lock().unwrap();
+ for (&level, &count) in lock.iter() {
+ if level == Level::INFO {
+ continue;
+ }
+ assert_eq!(
+ count, 1,
+ "level {:?} should have been seen 1 time by the WARN subscriber (after second set of events)",
+ level
+ );
+ }
+ }
+
+ info_handle.assert_finished();
+ warn_handle.assert_finished();
+}