dag-executor 0.1.0

A production-ready DAG executor with state management and advanced patterns
Documentation
//! Structured logging / tracing setup.

use std::sync::Once;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};

static INIT: Once = Once::new();

/// Initialize the global tracing subscriber.
///
/// Safe to call multiple times — only the first call takes effect (subsequent
/// calls are no-ops), which keeps tests and examples from panicking on a double
/// install. The filter is taken from `RUST_LOG` if set, otherwise from
/// `default_level`.
pub fn init(default_level: &str) {
    INIT.call_once(|| {
        let filter =
            EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(default_level));
        let registry = tracing_subscriber::registry().with(filter);

        // Pretty, human-readable logs by default; switch to JSON when
        // `DAG_LOG_JSON` is set (useful for log aggregation in production).
        if std::env::var("DAG_LOG_JSON").is_ok() {
            registry.with(fmt::layer().json()).init();
        } else {
            registry.with(fmt::layer().compact()).init();
        }
    });
}