Reviewed-on: #48 Co-authored-by: Felipe Contreras Salinas <felipe@bstr.cl> Co-committed-by: Felipe Contreras Salinas <felipe@bstr.cl>
20 lines
575 B
Rust
20 lines
575 B
Rust
//! 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(())
|
|
}
|