lemmy/src/lib.rs

28 lines
722 B
Rust
Raw Normal View History

#![recursion_limit = "512"]
2021-03-25 19:30:15 +00:00
pub mod api_routes;
pub mod code_migrations;
pub mod root_span_builder;
pub mod scheduled_tasks;
2021-11-23 12:16:47 +00:00
use lemmy_utils::LemmyError;
use tracing::subscriber::set_global_default;
use tracing_error::ErrorLayer;
use tracing_log::LogTracer;
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
2021-11-23 12:16:47 +00:00
pub fn init_tracing() -> Result<(), LemmyError> {
LogTracer::init()?;
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
let format_layer = tracing_subscriber::fmt::layer();
2021-11-23 12:16:47 +00:00
let subscriber = Registry::default()
.with(env_filter)
.with(format_layer)
.with(ErrorLayer::default());
set_global_default(subscriber)?;
Ok(())
}