pipey 0.2.1

A lightweight HTTP-to-WebSocket event delivery service.
Documentation
//! Tracing/logging initialization.
//!
//! Must be called once, at startup, before any `tracing::info!`/`warn!`/etc.
//! calls will produce output.

use tracing_subscriber::{EnvFilter, fmt, prelude::*};

/// Initialize the global tracing subscriber.
///
/// Log level is controlled by the `RUST_LOG` env var, e.g.:
///   RUST_LOG=info cargo run
///   RUST_LOG=pipey=debug,actix_web=info cargo run
///
/// Falls back to "info" if RUST_LOG is not set.
pub fn init_tracing() {
    let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));

    tracing_subscriber::registry()
        .with(filter)
        .with(fmt::layer())
        .init();
}