From 6024747674caefdc0abdad3037185d745e33339a Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Sun, 21 Nov 2021 12:09:26 -0800 Subject: [PATCH] chore: remove *all* `extern crate` statements Depends on #1737 This branch removes all remaining `extern crate` statements. Most of these are in old code and were not removed when updating to Rust 2018. Whoops! Our MSRV no longer requires `extern crate`, so we don't need these. The exception is `extern crate` statements for `std` and `alloc`, which are still the way these libraries are included explicitly when building for `no_std` platforms. In some cases, the tests had to explicitly import the `span!` and `event!` macros at every use, because their names conflict with the `span` and `event` modules in the test support code. Oh well. --- tracing-core/src/callsite.rs | 1 + tracing-core/src/collect.rs | 3 +- tracing-core/src/lib.rs | 5 - tracing-serde/README.md | 4 - tracing/benches/global_subscriber.rs | 3 - tracing/benches/subscriber.rs | 3 - tracing/src/level_filters.rs | 2 +- tracing/src/lib.rs | 3 - tracing/test-log-support/src/lib.rs | 1 - .../test-log-support/tests/log_no_trace.rs | 6 +- .../test-log-support/tests/log_with_trace.rs | 4 +- .../span_activity_filtered_separately.rs | 6 +- .../tests/span_lifecycle_can_be_enabled.rs | 4 +- .../tests/span_lifecycle_defaults_off.rs | 4 +- .../tests/span_lifecycle_is_trace.rs | 4 +- .../tests/test.rs | 3 +- tracing/tests/collector.rs | 13 +- tracing/tests/event.rs | 35 +++--- .../filter_caching_is_lexically_scoped.rs | 4 +- ...s_are_not_reevaluated_for_the_same_span.rs | 5 +- ...re_reevaluated_for_different_call_sites.rs | 4 +- tracing/tests/macros.rs | 7 +- tracing/tests/span.rs | 111 +++++++++--------- 23 files changed, 95 insertions(+), 140 deletions(-) diff --git a/tracing-core/src/callsite.rs b/tracing-core/src/callsite.rs index 00cef02a4c..d52ca64efd 100644 --- a/tracing-core/src/callsite.rs +++ b/tracing-core/src/callsite.rs @@ -67,6 +67,7 @@ pub use self::inner::{rebuild_interest_cache, register}; #[cfg(feature = "std")] mod inner { use super::*; + use lazy_static::lazy_static; use std::sync::RwLock; use std::vec::Vec; diff --git a/tracing-core/src/collect.rs b/tracing-core/src/collect.rs index d136dde9a3..0308eb7c18 100644 --- a/tracing-core/src/collect.rs +++ b/tracing-core/src/collect.rs @@ -239,8 +239,7 @@ pub trait Collect: 'static { /// but values for them won't be recorded at this time. /// /// ```rust,ignore - /// #[macro_use] - /// extern crate tracing; + /// # use tracing::span; /// /// let mut span = span!("my_span", foo = 3, bar, baz); /// diff --git a/tracing-core/src/lib.rs b/tracing-core/src/lib.rs index 393f801edc..01451513b5 100644 --- a/tracing-core/src/lib.rs +++ b/tracing-core/src/lib.rs @@ -274,11 +274,6 @@ macro_rules! metadata { }; } -// std uses lazy_static from crates.io -#[cfg(feature = "std")] -#[macro_use] -extern crate lazy_static; - // Facade module: `no_std` uses spinlocks, `std` uses the mutexes in the standard library #[cfg(not(feature = "std"))] #[doc(hidden)] diff --git a/tracing-serde/README.md b/tracing-serde/README.md index b0cbc7f320..deb4f8bb64 100644 --- a/tracing-serde/README.md +++ b/tracing-serde/README.md @@ -53,10 +53,6 @@ tracing-serde = "0.1" Next, add this to your crate: ```rust -#[macro_use] -extern crate tracing; -extern crate tracing_serde; - use tracing_serde::AsSerde; ``` diff --git a/tracing/benches/global_subscriber.rs b/tracing/benches/global_subscriber.rs index d5e044726d..c020775dd8 100644 --- a/tracing/benches/global_subscriber.rs +++ b/tracing/benches/global_subscriber.rs @@ -1,6 +1,3 @@ -extern crate criterion; -extern crate tracing; - use criterion::{black_box, criterion_group, criterion_main, Criterion}; use tracing::Level; diff --git a/tracing/benches/subscriber.rs b/tracing/benches/subscriber.rs index 2b486e946b..3fda5283e0 100644 --- a/tracing/benches/subscriber.rs +++ b/tracing/benches/subscriber.rs @@ -1,6 +1,3 @@ -extern crate criterion; -extern crate tracing; - use criterion::{black_box, criterion_group, criterion_main, Criterion}; use tracing::Level; diff --git a/tracing/src/level_filters.rs b/tracing/src/level_filters.rs index 4e8cc0ea43..4181dc3bf7 100644 --- a/tracing/src/level_filters.rs +++ b/tracing/src/level_filters.rs @@ -65,7 +65,7 @@ pub use tracing_core::{metadata::ParseLevelFilterError, LevelFilter}; /// [module-level documentation]: self#compile-time-filters pub const STATIC_MAX_LEVEL: LevelFilter = MAX_LEVEL; -cfg_if! { +cfg_if::cfg_if! { if #[cfg(all(not(debug_assertions), feature = "release_max_level_off"))] { const MAX_LEVEL: LevelFilter = LevelFilter::OFF; } else if #[cfg(all(not(debug_assertions), feature = "release_max_level_error"))] { diff --git a/tracing/src/lib.rs b/tracing/src/lib.rs index 1ed8c90dc5..120069fa35 100644 --- a/tracing/src/lib.rs +++ b/tracing/src/lib.rs @@ -929,9 +929,6 @@ while_true )] -#[macro_use] -extern crate cfg_if; - #[cfg(feature = "log")] #[doc(hidden)] pub use log; diff --git a/tracing/test-log-support/src/lib.rs b/tracing/test-log-support/src/lib.rs index 7e76428892..e63257445f 100644 --- a/tracing/test-log-support/src/lib.rs +++ b/tracing/test-log-support/src/lib.rs @@ -1,4 +1,3 @@ -extern crate log; use log::{LevelFilter, Log, Metadata, Record}; use std::sync::{Arc, Mutex}; diff --git a/tracing/test-log-support/tests/log_no_trace.rs b/tracing/test-log-support/tests/log_no_trace.rs index 2e71896e08..cc29592018 100644 --- a/tracing/test-log-support/tests/log_no_trace.rs +++ b/tracing/test-log-support/tests/log_no_trace.rs @@ -1,9 +1,5 @@ -#[macro_use] -extern crate tracing; -extern crate test_log_support; - use test_log_support::Test; -use tracing::Level; +use tracing::{debug, error, info, trace, warn, Level}; #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] diff --git a/tracing/test-log-support/tests/log_with_trace.rs b/tracing/test-log-support/tests/log_with_trace.rs index e6856eba46..b8eb0a8828 100644 --- a/tracing/test-log-support/tests/log_with_trace.rs +++ b/tracing/test-log-support/tests/log_with_trace.rs @@ -1,6 +1,4 @@ -#[macro_use] -extern crate tracing; -extern crate test_log_support; +use tracing::{debug, error, info, span, trace, warn, Level}; use test_log_support::Test; use tracing::Level; diff --git a/tracing/test-log-support/tests/span_activity_filtered_separately.rs b/tracing/test-log-support/tests/span_activity_filtered_separately.rs index 3f28822c40..675e82fb08 100644 --- a/tracing/test-log-support/tests/span_activity_filtered_separately.rs +++ b/tracing/test-log-support/tests/span_activity_filtered_separately.rs @@ -1,9 +1,5 @@ -#[macro_use] -extern crate tracing; -extern crate test_log_support; - use test_log_support::Test; -use tracing::Level; +use tracing::{debug, error, info, span, trace, warn, Level}; #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] diff --git a/tracing/test-log-support/tests/span_lifecycle_can_be_enabled.rs b/tracing/test-log-support/tests/span_lifecycle_can_be_enabled.rs index ee099c0966..8c86c204fb 100644 --- a/tracing/test-log-support/tests/span_lifecycle_can_be_enabled.rs +++ b/tracing/test-log-support/tests/span_lifecycle_can_be_enabled.rs @@ -1,6 +1,4 @@ -#[macro_use] -extern crate tracing; -extern crate test_log_support; +use tracing::{debug, error, info, span, trace, warn, Level}; use test_log_support::Test; use tracing::Level; diff --git a/tracing/test-log-support/tests/span_lifecycle_defaults_off.rs b/tracing/test-log-support/tests/span_lifecycle_defaults_off.rs index a966569cbb..aac9b76da0 100644 --- a/tracing/test-log-support/tests/span_lifecycle_defaults_off.rs +++ b/tracing/test-log-support/tests/span_lifecycle_defaults_off.rs @@ -1,6 +1,4 @@ -#[macro_use] -extern crate tracing; -extern crate test_log_support; +use tracing::{debug, error, info, span, trace, warn, Level}; use test_log_support::Test; use tracing::Level; diff --git a/tracing/test-log-support/tests/span_lifecycle_is_trace.rs b/tracing/test-log-support/tests/span_lifecycle_is_trace.rs index 62ac7194a6..80c348d8e4 100644 --- a/tracing/test-log-support/tests/span_lifecycle_is_trace.rs +++ b/tracing/test-log-support/tests/span_lifecycle_is_trace.rs @@ -1,6 +1,4 @@ -#[macro_use] -extern crate tracing; -extern crate test_log_support; +use tracing::{debug, error, info, span, trace, warn, Level}; use test_log_support::Test; use tracing::Level; diff --git a/tracing/test_static_max_level_features/tests/test.rs b/tracing/test_static_max_level_features/tests/test.rs index 18395601f7..1761f2b3f8 100644 --- a/tracing/test_static_max_level_features/tests/test.rs +++ b/tracing/test_static_max_level_features/tests/test.rs @@ -1,5 +1,4 @@ -#[macro_use] -extern crate tracing; +use tracing::{debug, error, info, trace, warn, Level}; use std::sync::{Arc, Mutex}; use tracing::span::{Attributes, Record}; diff --git a/tracing/tests/collector.rs b/tracing/tests/collector.rs index f4409c575f..64a14825aa 100644 --- a/tracing/tests/collector.rs +++ b/tracing/tests/collector.rs @@ -5,9 +5,6 @@ // The alternative would be for each of these tests to be defined in a separate // file, which is :( #![cfg(feature = "std")] - -#[macro_use] -extern crate tracing; use tracing::{ collect::{with_default, Collect, Interest}, field::display, @@ -34,7 +31,7 @@ fn event_macros_dont_infinite_loop() { fn enabled(&self, meta: &Metadata<'_>) -> bool { assert!(meta.fields().iter().any(|f| f.name() == "foo")); - event!(Level::TRACE, bar = false); + tracing::event!(Level::TRACE, bar = false); true } @@ -48,7 +45,7 @@ fn event_macros_dont_infinite_loop() { fn event(&self, event: &Event<'_>) { assert!(event.metadata().fields().iter().any(|f| f.name() == "foo")); - event!(Level::TRACE, baz = false); + tracing::event!(Level::TRACE, baz = false); } fn enter(&self, _: &Id) {} @@ -61,7 +58,7 @@ fn event_macros_dont_infinite_loop() { } with_default(TestCollector, || { - event!(Level::TRACE, foo = false); + tracing::event!(Level::TRACE, foo = false); }) } @@ -85,7 +82,7 @@ fn boxed_collector() { with_default(collector, || { let from = "my span"; - let span = span!( + let span = tracing::span!( Level::TRACE, "foo", bar = format_args!("hello from {}", from) @@ -123,7 +120,7 @@ fn arced_collector() { // Test using a clone of the `Arc`ed collector with_default(collector.clone(), || { let from = "my span"; - let span = span!( + let span = tracing::span!( Level::TRACE, "foo", bar = format_args!("hello from {}", from) diff --git a/tracing/tests/event.rs b/tracing/tests/event.rs index 16180fa65a..967b39d289 100644 --- a/tracing/tests/event.rs +++ b/tracing/tests/event.rs @@ -5,17 +5,15 @@ // The alternative would be for each of these tests to be defined in a separate // file, which is :( #![cfg(feature = "std")] - -#[macro_use] -extern crate tracing; mod support; use self::support::*; use tracing::{ collect::with_default, + debug, error, field::{debug, display}, - Level, + info, trace, warn, Level, }; macro_rules! event_without_message { @@ -61,13 +59,16 @@ event_without_message! {nonzeroi32_event_without_message: std::num::NonZeroI32:: fn event_with_message() { let (collector, handle) = collector::mock() .event(event::mock().with_fields(field::mock("message").with_value( - &tracing::field::debug(format_args!("hello from my event! yak shaved = {:?}", true)), + &tracing::field::debug(format_args!( + "hello from my tracing::event! yak shaved = {:?}", + true + )), ))) .done() .run_with_handle(); with_default(collector, || { - debug!("hello from my event! yak shaved = {:?}", true); + debug!("hello from my tracing::event! yak shaved = {:?}", true); }); handle.assert_finished(); @@ -84,7 +85,7 @@ fn message_without_delims() { .and(field::mock("question").with_value(&"life, the universe, and everything")) .and( field::mock("message").with_value(&tracing::field::debug(format_args!( - "hello from my event! tricky? {:?}!", + "hello from my tracing::event! tricky? {:?}!", true ))), ) @@ -155,7 +156,7 @@ fn one_with_everything() { .run_with_handle(); with_default(collector, || { - event!( + tracing::event!( target: "whatever", Level::ERROR, { foo = 666, bar = false, like_a_butterfly = 42.0 }, @@ -181,7 +182,7 @@ fn moved_field() { .run_with_handle(); with_default(collector, || { let from = "my event"; - event!(Level::INFO, foo = display(format!("hello from {}", from))) + tracing::event!(Level::INFO, foo = display(format!("hello from {}", from))) }); handle.assert_finished(); @@ -202,7 +203,7 @@ fn dotted_field_name() { .done() .run_with_handle(); with_default(collector, || { - event!(Level::INFO, foo.bar = true, foo.baz = false); + tracing::event!(Level::INFO, foo.bar = true, foo.baz = false); }); handle.assert_finished(); @@ -224,7 +225,7 @@ fn borrowed_field() { with_default(collector, || { let from = "my event"; let mut message = format!("hello from {}", from); - event!(Level::INFO, foo = display(&message)); + tracing::event!(Level::INFO, foo = display(&message)); message.push_str(", which happened!"); }); @@ -286,7 +287,7 @@ fn display_shorthand() { .done() .run_with_handle(); with_default(collector, || { - event!(Level::TRACE, my_field = %"hello world"); + tracing::event!(Level::TRACE, my_field = %"hello world"); }); handle.assert_finished(); @@ -306,7 +307,7 @@ fn debug_shorthand() { .done() .run_with_handle(); with_default(collector, || { - event!(Level::TRACE, my_field = ?"hello world"); + tracing::event!(Level::TRACE, my_field = ?"hello world"); }); handle.assert_finished(); @@ -327,7 +328,7 @@ fn both_shorthands() { .done() .run_with_handle(); with_default(collector, || { - event!(Level::TRACE, display_field = %"hello world", debug_field = ?"hello world"); + tracing::event!(Level::TRACE, display_field = %"hello world", debug_field = ?"hello world"); }); handle.assert_finished(); @@ -343,8 +344,8 @@ fn explicit_child() { .run_with_handle(); with_default(collector, || { - let foo = span!(Level::TRACE, "foo"); - event!(parent: foo.id(), Level::TRACE, "bar"); + let foo = tracing::span!(Level::TRACE, "foo"); + tracing::event!(parent: foo.id(), Level::TRACE, "bar"); }); handle.assert_finished(); @@ -364,7 +365,7 @@ fn explicit_child_at_levels() { .run_with_handle(); with_default(collector, || { - let foo = span!(Level::TRACE, "foo"); + let foo = tracing::span!(Level::TRACE, "foo"); trace!(parent: foo.id(), "a"); debug!(parent: foo.id(), "b"); info!(parent: foo.id(), "c"); diff --git a/tracing/tests/filter_caching_is_lexically_scoped.rs b/tracing/tests/filter_caching_is_lexically_scoped.rs index 13fbcfd50c..5a15889d4d 100644 --- a/tracing/tests/filter_caching_is_lexically_scoped.rs +++ b/tracing/tests/filter_caching_is_lexically_scoped.rs @@ -11,12 +11,10 @@ #[cfg(not(feature = "std"))] extern crate std; -#[macro_use] -extern crate tracing; mod support; use self::support::*; -use tracing::Level; +use tracing::{span, Level}; use std::sync::{ atomic::{AtomicUsize, Ordering}, diff --git a/tracing/tests/filters_are_not_reevaluated_for_the_same_span.rs b/tracing/tests/filters_are_not_reevaluated_for_the_same_span.rs index aea946ea1b..ef12aefe7c 100644 --- a/tracing/tests/filters_are_not_reevaluated_for_the_same_span.rs +++ b/tracing/tests/filters_are_not_reevaluated_for_the_same_span.rs @@ -10,13 +10,10 @@ #[cfg(not(feature = "std"))] extern crate std; - -#[macro_use] -extern crate tracing; mod support; use self::support::*; -use tracing::Level; +use tracing::{span, Level}; use std::sync::{ atomic::{AtomicUsize, Ordering}, diff --git a/tracing/tests/filters_are_reevaluated_for_different_call_sites.rs b/tracing/tests/filters_are_reevaluated_for_different_call_sites.rs index 2734b0b3f5..87bad8794d 100644 --- a/tracing/tests/filters_are_reevaluated_for_different_call_sites.rs +++ b/tracing/tests/filters_are_reevaluated_for_different_call_sites.rs @@ -11,12 +11,10 @@ #[cfg(not(feature = "std"))] extern crate std; -#[macro_use] -extern crate tracing; +use tracing::{span, Level}; mod support; use self::support::*; -use tracing::Level; use std::sync::{ atomic::{AtomicUsize, Ordering}, diff --git a/tracing/tests/macros.rs b/tracing/tests/macros.rs index 445d17aa43..420319d373 100644 --- a/tracing/tests/macros.rs +++ b/tracing/tests/macros.rs @@ -1,8 +1,9 @@ #![deny(warnings)] -use tracing::Level; +use tracing::{ + callsite, debug, debug_span, error, error_span, event, info, info_span, span, trace, + trace_span, warn, warn_span, Level, +}; -#[macro_use] -extern crate tracing; // Tests that macros work across various invocation syntax. // // These are quite repetitive, and _could_ be generated by a macro. However, diff --git a/tracing/tests/span.rs b/tracing/tests/span.rs index 73a5d7ddf1..2218d54c58 100644 --- a/tracing/tests/span.rs +++ b/tracing/tests/span.rs @@ -3,8 +3,6 @@ // with the standard lib disabled. #![cfg(feature = "std")] -#[macro_use] -extern crate tracing; mod support; use self::support::*; @@ -23,7 +21,7 @@ fn handles_to_the_same_span_are_equal() { // won't enter any spans in this test, so the collector won't actually // expect to see any spans. with_default(collector::mock().run(), || { - let foo1 = span!(Level::TRACE, "foo"); + let foo1 = tracing::span!(Level::TRACE, "foo"); let foo2 = foo1.clone(); // Two handles that point to the same span are equal. assert_eq!(foo1, foo2); @@ -36,8 +34,8 @@ fn handles_to_different_spans_are_not_equal() { with_default(collector::mock().run(), || { // Even though these spans have the same name and fields, they will have // differing metadata, since they were created on different lines. - let foo1 = span!(Level::TRACE, "foo", bar = 1u64, baz = false); - let foo2 = span!(Level::TRACE, "foo", bar = 1u64, baz = false); + let foo1 = tracing::span!(Level::TRACE, "foo", bar = 1u64, baz = false); + let foo2 = tracing::span!(Level::TRACE, "foo", bar = 1u64, baz = false); assert_ne!(foo1, foo2); }); @@ -49,7 +47,7 @@ fn handles_to_different_spans_with_the_same_metadata_are_not_equal() { // Every time time this function is called, it will return a _new // instance_ of a span with the same metadata, name, and fields. fn make_span() -> Span { - span!(Level::TRACE, "foo", bar = 1u64, baz = false) + tracing::span!(Level::TRACE, "foo", bar = 1u64, baz = false) } with_default(collector::mock().run(), || { @@ -75,7 +73,7 @@ fn spans_always_go_to_the_subscriber_that_tagged_them() { let collector2 = collector::mock().run(); let foo = with_default(collector1, || { - let foo = span!(Level::TRACE, "foo"); + let foo = tracing::span!(Level::TRACE, "foo"); foo.in_scope(|| {}); foo }); @@ -100,7 +98,7 @@ fn spans_always_go_to_the_subscriber_that_tagged_them_even_across_threads() { .done() .run(); let foo = with_default(collector1, || { - let foo = span!(Level::TRACE, "foo"); + let foo = tracing::span!(Level::TRACE, "foo"); foo.in_scope(|| {}); foo }); @@ -126,7 +124,7 @@ fn dropping_a_span_calls_drop_span() { .done() .run_with_handle(); with_default(collector, || { - let span = span!(Level::TRACE, "foo"); + let span = tracing::span!(Level::TRACE, "foo"); span.in_scope(|| {}); drop(span); }); @@ -145,8 +143,8 @@ fn span_closes_after_event() { .done() .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "foo").in_scope(|| { - event!(Level::DEBUG, {}, "my event!"); + tracing::span!(Level::TRACE, "foo").in_scope(|| { + tracing::event!(Level::DEBUG, {}, "my tracing::event!"); }); }); @@ -167,10 +165,10 @@ fn new_span_after_event() { .done() .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "foo").in_scope(|| { - event!(Level::DEBUG, {}, "my event!"); + tracing::span!(Level::TRACE, "foo").in_scope(|| { + tracing::event!(Level::DEBUG, {}, "my tracing::event!"); }); - span!(Level::TRACE, "bar").in_scope(|| {}); + tracing::span!(Level::TRACE, "bar").in_scope(|| {}); }); handle.assert_finished(); @@ -187,8 +185,8 @@ fn event_outside_of_span() { .done() .run_with_handle(); with_default(collector, || { - debug!("my event!"); - span!(Level::TRACE, "foo").in_scope(|| {}); + tracing::debug!("my tracing::event!"); + tracing::span!(Level::TRACE, "foo").in_scope(|| {}); }); handle.assert_finished(); @@ -201,7 +199,7 @@ fn cloning_a_span_calls_clone_span() { .clone_span(span::mock().named("foo")) .run_with_handle(); with_default(collector, || { - let span = span!(Level::TRACE, "foo"); + let span = tracing::span!(Level::TRACE, "foo"); // Allow the "redundant" `.clone` since it is used to call into the `.clone_span` hook. #[allow(clippy::redundant_clone)] let _span2 = span.clone(); @@ -219,7 +217,7 @@ fn drop_span_when_exiting_dispatchers_context() { .drop_span(span::mock().named("foo")) .run_with_handle(); with_default(collector, || { - let span = span!(Level::TRACE, "foo"); + let span = tracing::span!(Level::TRACE, "foo"); let _span2 = span.clone(); drop(span); }); @@ -242,7 +240,7 @@ fn clone_and_drop_span_always_go_to_the_subscriber_that_tagged_the_span() { let subscriber2 = collector::mock().done().run(); let foo = with_default(subscriber1, || { - let foo = span!(Level::TRACE, "foo"); + let foo = tracing::span!(Level::TRACE, "foo"); foo.in_scope(|| {}); foo }); @@ -268,7 +266,7 @@ fn span_closes_when_exited() { .done() .run_with_handle(); with_default(collector, || { - let foo = span!(Level::TRACE, "foo"); + let foo = tracing::span!(Level::TRACE, "foo"); foo.in_scope(|| {}); @@ -289,9 +287,9 @@ fn enter() { .done() .run_with_handle(); with_default(collector, || { - let foo = span!(Level::TRACE, "foo"); + let foo = tracing::span!(Level::TRACE, "foo"); let _enter = foo.enter(); - debug!("dropping guard..."); + tracing::debug!("dropping guard..."); }); handle.assert_finished(); @@ -308,8 +306,8 @@ fn entered() { .done() .run_with_handle(); with_default(collector, || { - let _span = span!(Level::TRACE, "foo").entered(); - debug!("dropping guard..."); + let _span = tracing::span!(Level::TRACE, "foo").entered(); + tracing::debug!("dropping guard..."); }); handle.assert_finished(); @@ -326,9 +324,9 @@ fn entered_api() { .done() .run_with_handle(); with_default(collector, || { - let span = span!(Level::TRACE, "foo").entered(); + let span = tracing::span!(Level::TRACE, "foo").entered(); let _derefs_to_span = span.id(); - debug!("exiting span..."); + tracing::debug!("exiting span..."); let _: Span = span.exit(); }); @@ -353,7 +351,7 @@ fn moved_field() { .run_with_handle(); with_default(collector, || { let from = "my span"; - let span = span!( + let span = tracing::span!( Level::TRACE, "foo", bar = display(format!("hello from {}", from)) @@ -376,7 +374,7 @@ fn dotted_field_name() { .done() .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "foo", fields.bar = true); + tracing::span!(Level::TRACE, "foo", fields.bar = true); }); handle.assert_finished(); @@ -402,7 +400,7 @@ fn borrowed_field() { with_default(collector, || { let from = "my span"; let mut message = format!("hello from {}", from); - let span = span!(Level::TRACE, "foo", bar = display(&message)); + let span = tracing::span!(Level::TRACE, "foo", bar = display(&message)); span.in_scope(|| { message.insert_str(10, " inside"); }); @@ -449,8 +447,8 @@ fn move_field_out_of_struct() { x: 3.234, y: -1.223, }; - let foo = span!(Level::TRACE, "foo", x = debug(pos.x), y = debug(pos.y)); - let bar = span!(Level::TRACE, "bar", position = debug(pos)); + let foo = tracing::span!(Level::TRACE, "foo", x = debug(pos.x), y = debug(pos.y)); + let bar = tracing::span!(Level::TRACE, "bar", position = debug(pos)); foo.in_scope(|| {}); bar.in_scope(|| {}); }); @@ -473,7 +471,7 @@ fn float_values() { .run_with_handle(); with_default(collector, || { - let foo = span!(Level::TRACE, "foo", x = 3.234, y = -1.223); + let foo = tracing::span!(Level::TRACE, "foo", x = 3.234, y = -1.223); foo.in_scope(|| {}); }); @@ -504,7 +502,7 @@ fn add_field_after_new_span() { .run_with_handle(); with_default(subscriber, || { - let span = span!(Level::TRACE, "foo", bar = 5, baz = false); + let span = tracing::span!(Level::TRACE, "foo", bar = 5, baz = false); span.record("baz", &true); span.in_scope(|| {}) }); @@ -532,7 +530,7 @@ fn add_fields_only_after_new_span() { .run_with_handle(); with_default(subscriber, || { - let span = span!(Level::TRACE, "foo", bar = _, baz = _); + let span = tracing::span!(Level::TRACE, "foo", bar = _, baz = _); span.record("bar", &5); span.record("baz", &true); span.in_scope(|| {}) @@ -565,7 +563,7 @@ fn record_new_value_for_field() { .run_with_handle(); with_default(collector, || { - let span = span!(Level::TRACE, "foo", bar = 5, baz = false); + let span = tracing::span!(Level::TRACE, "foo", bar = 5, baz = false); span.record("baz", &true); span.in_scope(|| {}) }); @@ -600,7 +598,7 @@ fn record_new_values_for_fields() { .run_with_handle(); with_default(collector, || { - let span = span!(Level::TRACE, "foo", bar = 4, baz = false); + let span = tracing::span!(Level::TRACE, "foo", bar = 4, baz = false); span.record("bar", &5); span.record("baz", &true); span.in_scope(|| {}) @@ -623,7 +621,7 @@ fn new_span_with_target_and_log_level() { .run_with_handle(); with_default(collector, || { - span!(target: "app_span", Level::DEBUG, "foo"); + tracing::span!(target: "app_span", Level::DEBUG, "foo"); }); handle.assert_finished(); @@ -638,7 +636,7 @@ fn explicit_root_span_is_root() { .run_with_handle(); with_default(collector, || { - span!(parent: None, Level::TRACE, "foo"); + tracing::span!(parent: None, Level::TRACE, "foo"); }); handle.assert_finished(); @@ -656,8 +654,8 @@ fn explicit_root_span_is_root_regardless_of_ctx() { .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "foo").in_scope(|| { - span!(parent: None, Level::TRACE, "bar"); + tracing::span!(Level::TRACE, "foo").in_scope(|| { + tracing::span!(parent: None, Level::TRACE, "bar"); }) }); @@ -674,8 +672,8 @@ fn explicit_child() { .run_with_handle(); with_default(collector, || { - let foo = span!(Level::TRACE, "foo"); - span!(parent: foo.id(), Level::TRACE, "bar"); + let foo = tracing::span!(Level::TRACE, "foo"); + tracing::span!(parent: foo.id(), Level::TRACE, "bar"); }); handle.assert_finished(); @@ -695,12 +693,12 @@ fn explicit_child_at_levels() { .run_with_handle(); with_default(collector, || { - let foo = span!(Level::TRACE, "foo"); - trace_span!(parent: foo.id(), "a"); - debug_span!(parent: foo.id(), "b"); - info_span!(parent: foo.id(), "c"); - warn_span!(parent: foo.id(), "d"); - error_span!(parent: foo.id(), "e"); + let foo = tracing::span!(Level::TRACE, "foo"); + tracing::trace_span!(parent: foo.id(), "a"); + tracing::debug_span!(parent: foo.id(), "b"); + tracing::info_span!(parent: foo.id(), "c"); + tracing::warn_span!(parent: foo.id(), "d"); + tracing::error_span!(parent: foo.id(), "e"); }); handle.assert_finished(); @@ -719,8 +717,9 @@ fn explicit_child_regardless_of_ctx() { .run_with_handle(); with_default(collector, || { - let foo = span!(Level::TRACE, "foo"); - span!(Level::TRACE, "bar").in_scope(|| span!(parent: foo.id(), Level::TRACE, "baz")) + let foo = tracing::span!(Level::TRACE, "foo"); + tracing::span!(Level::TRACE, "bar") + .in_scope(|| tracing::span!(parent: foo.id(), Level::TRACE, "baz")) }); handle.assert_finished(); @@ -735,7 +734,7 @@ fn contextual_root() { .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "foo"); + tracing::span!(Level::TRACE, "foo"); }); handle.assert_finished(); @@ -757,8 +756,8 @@ fn contextual_child() { .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "foo").in_scope(|| { - span!(Level::TRACE, "bar"); + tracing::span!(Level::TRACE, "foo").in_scope(|| { + tracing::span!(Level::TRACE, "bar"); }) }); @@ -779,7 +778,7 @@ fn display_shorthand() { .done() .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "my_span", my_field = %"hello world"); + tracing::span!(Level::TRACE, "my_span", my_field = %"hello world"); }); handle.assert_finished(); @@ -799,7 +798,7 @@ fn debug_shorthand() { .done() .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "my_span", my_field = ?"hello world"); + tracing::span!(Level::TRACE, "my_span", my_field = ?"hello world"); }); handle.assert_finished(); @@ -820,7 +819,7 @@ fn both_shorthands() { .done() .run_with_handle(); with_default(collector, || { - span!(Level::TRACE, "my_span", display_field = %"hello world", debug_field = ?"hello world"); + tracing::span!(Level::TRACE, "my_span", display_field = %"hello world", debug_field = ?"hello world"); }); handle.assert_finished();