2019-08-14 02:52:43 +00:00
|
|
|
#![recursion_limit = "512"]
|
2021-03-25 19:30:15 +00:00
|
|
|
pub mod api_routes;
|
2020-07-10 18:15:41 +00:00
|
|
|
pub mod code_migrations;
|
2021-01-29 16:38:27 +00:00
|
|
|
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::{fmt::format::FmtSpan, layer::SubscriberExt, EnvFilter, Registry};
|
|
|
|
|
|
|
|
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()
|
|
|
|
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
|
|
|
|
.pretty();
|
|
|
|
|
|
|
|
let subscriber = Registry::default()
|
|
|
|
.with(env_filter)
|
|
|
|
.with(format_layer)
|
|
|
|
.with(ErrorLayer::default());
|
|
|
|
|
|
|
|
set_global_default(subscriber)?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|