diff --git a/src/main.rs b/src/main.rs index 2bfd273..ef60524 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod api; mod management; mod sse_handler; +mod tracing_handler; use cm_lib::{ hx_request::HxRequest, @@ -31,7 +32,6 @@ use diesel_async::{ use dotenvy::dotenv; use std::{net::SocketAddr, time::Duration}; use tower_http::services::{ServeDir, ServeFile}; -use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use crate::templates::*; @@ -66,13 +66,7 @@ impl AppState { #[tokio::main] async fn main() { // initialize tracing - tracing_subscriber::registry() - .with( - tracing_subscriber::EnvFilter::try_from_default_env() - .unwrap_or_else(|_| "clubmanager=debug,tower_http=debug".into()), - ) - .with(tracing_subscriber::fmt::layer()) - .init(); + tracing_handler::init_tracing(); let state = AppState::init(); diff --git a/src/tracing_handler.rs b/src/tracing_handler.rs new file mode 100644 index 0000000..45e6320 --- /dev/null +++ b/src/tracing_handler.rs @@ -0,0 +1,11 @@ +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; + +pub fn init_tracing() { + tracing_subscriber::registry() + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "clubmanager=debug,tower_http=debug".into()), + ) + .with(tracing_subscriber::fmt::layer()) + .init(); +}