cucumber-rs / cucumber

Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
https://cucumber-rs.github.io/cucumber/main
Apache License 2.0
563 stars 69 forks source link

"A global default trace dispatcher has already been set" #295

Closed slyons closed 1 year ago

slyons commented 1 year ago

Super excited about the tracing integration, but I've run into a bit of a snag.

Following the tracing crate's instructions, I have this at the start of main:

let subscriber = FmtSubscriber::builder()
        // all spans/events with a level higher than TRACE (e.g, debug, info, warn, etc.)
        // will be written to stdout.
        .with_max_level(Level::TRACE)
        // completes the builder.
        .finish();

    tracing::subscriber::set_global_default(subscriber)
        .expect("setting default subscriber failed");

And when I use init_tracing for my World:

    WorldSeer::cucumber()
        .after(|_, _, _, ev, world| {
            async {
                match world {
                    Some(world) => world.end().await,
                    None => ()
                };

            }.boxed()

        })
        .init_tracing()
        .run_and_exit("features/demo.feature")

I get the following exception when I try to run:

thread 'main' panicked at 'failed to set global default subscriber: 
SetGlobalDefaultError("a global default trace dispatcher has already been set")'