use tracing_subscriber::EnvFilter;

pub fn init(filter: &str) {
    let filter = EnvFilter::try_new(filter).unwrap_or_else(|_| EnvFilter::new("info"));
    let subscriber = tracing_subscriber::fmt()
        .with_env_filter(filter)
        .with_target(true)
        .with_thread_ids(true)
        .with_thread_names(true)
        .compact()
        .finish();

    tracing::subscriber::set_global_default(subscriber)
        .expect("failed to install tracing subscriber");
}
