relocate tracing code

This commit is contained in:
Zynh0722 2023-11-05 11:49:25 -08:00
parent d4ef460321
commit d290ccf8d0
2 changed files with 13 additions and 8 deletions

View file

@ -1,6 +1,7 @@
mod api; mod api;
mod management; mod management;
mod sse_handler; mod sse_handler;
mod tracing_handler;
use cm_lib::{ use cm_lib::{
hx_request::HxRequest, hx_request::HxRequest,
@ -31,7 +32,6 @@ use diesel_async::{
use dotenvy::dotenv; use dotenvy::dotenv;
use std::{net::SocketAddr, time::Duration}; use std::{net::SocketAddr, time::Duration};
use tower_http::services::{ServeDir, ServeFile}; use tower_http::services::{ServeDir, ServeFile};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use crate::templates::*; use crate::templates::*;
@ -66,13 +66,7 @@ impl AppState {
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
// initialize tracing // initialize tracing
tracing_subscriber::registry() tracing_handler::init_tracing();
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "clubmanager=debug,tower_http=debug".into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
let state = AppState::init(); let state = AppState::init();

11
src/tracing_handler.rs Normal file
View file

@ -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();
}