Skip to content

How to setup simultaneous with features? #2300

Answered by davidbarsky
TornaxO7 asked this question in Q&A
Discussion options

You must be logged in to vote

Have you read https://docs.rs/tracing-subscriber/latest/tracing_subscriber/layer/index.html#runtime-configuration-with-layers, by any chance? I'd suggest dynamic configuration through that approach instead of using feature flags.

That being said, something like this should work:

use tracing::Subscriber;
use tracing_subscriber::{filter::EnvFilter, fmt, layer::SubscriberExt};

fn main() {
    let subscriber: Box<dyn Subscriber + Send + Sync + 'static> = get_subscriber();
    tracing::subscriber::set_global_default(subscriber)
        .expect("Couldn't setup global subscriber (logger)");
}

fn get_subscriber() -> Box<dyn Subscriber + Send + Sync + 'static> {
    let subscriber = tracing_subs…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TornaxO7
Comment options

@davidbarsky
Comment options

Answer selected by TornaxO7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants