huellas/src/logging.rs

21 lines
575 B
Rust
Raw Permalink Normal View History

//! Service logging.
use anyhow::Result;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
/// Setups logging.
///
/// # Errors
/// This function can return an error if called repeatedly or if logging/tracing was already setup
/// by another means.
pub fn setup() -> Result<()> {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "huellas=debug".into()),
)
.with(tracing_subscriber::fmt::layer())
.try_init()?;
Ok(())
}