Sha256: 338846cd519e9a3a6895f958b11bd3f97e4350d08adb50f95b8552113a593b0d

Contents?: true

Size: 1.31 KB

Versions: 32

Compression:

Stored size: 1.31 KB

Contents

mod common;

use common::*;
use tracing_core::{
    dispatcher::{self, Dispatch},
    subscriber::NoSubscriber,
};

/// This test reproduces the following issues:
/// - https://github.com/tokio-rs/tracing/issues/2587
/// - https://github.com/tokio-rs/tracing/issues/2411
/// - https://github.com/tokio-rs/tracing/issues/2436
#[test]
fn local_dispatch_before_init() {
    dispatcher::get_default(|current| assert!(dbg!(current).is::<NoSubscriber>()));

    // Temporarily override the default dispatcher with a scoped dispatcher.
    // Using a scoped dispatcher makes the thread local state attempt to cache
    // the scoped default.
    #[cfg(feature = "std")]
    {
        dispatcher::with_default(&Dispatch::new(TestSubscriberB), || {
            dispatcher::get_default(|current| {
                assert!(
                    dbg!(current).is::<TestSubscriberB>(),
                    "overriden subscriber not set",
                );
            })
        })
    }

    dispatcher::get_default(|current| assert!(current.is::<NoSubscriber>()));

    dispatcher::set_global_default(Dispatch::new(TestSubscriberA))
        .expect("set global dispatch failed");

    dispatcher::get_default(|current| {
        assert!(
            dbg!(current).is::<TestSubscriberA>(),
            "default subscriber not set"
        );
    });
}

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
wasmtime-30.0.2 ./ext/cargo-vendor/tracing-core-0.1.33/tests/local_dispatch_before_init.rs
wasmtime-29.0.0 ./ext/cargo-vendor/tracing-core-0.1.33/tests/local_dispatch_before_init.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tracing-core-0.1.33/tests/local_dispatch_before_init.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-25.0.2 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-25.0.1 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-25.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-24.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-23.0.2 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-22.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-21.0.1 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-20.0.2 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-20.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-18.0.3 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-17.0.1 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-17.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-16.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-15.0.1 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs
wasmtime-15.0.0 ./ext/cargo-vendor/tracing-core-0.1.32/tests/local_dispatch_before_init.rs