From 50f84d43f5eebbe13c7a1ab6ca44b4cced74371e Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 29 Jan 2024 13:36:10 +0100 Subject: [PATCH] init commit --- meilisearch/src/main.rs | 9 +++++++++ meilisearch/src/routes/logs.rs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/meilisearch/src/main.rs b/meilisearch/src/main.rs index 75308258e..863db22d0 100644 --- a/meilisearch/src/main.rs +++ b/meilisearch/src/main.rs @@ -27,6 +27,10 @@ static ALLOC: MiMalloc = MiMalloc; #[global_allocator] static ALLOC: stats_alloc::StatsAlloc = stats_alloc::StatsAlloc::new(MiMalloc); +fn f() -> Option>> { + None +} + /// does all the setup before meilisearch is launched fn setup(opt: &Opt) -> anyhow::Result<()> { let now = time::OffsetDateTime::now_utc(); @@ -40,7 +44,12 @@ fn setup(opt: &Opt) -> anyhow::Result<()> { #[cfg(feature = "stats_alloc")] let (mut trace, layer) = tracing_trace::Trace::with_stats_alloc(file, &ALLOC); + // let (route_layer, route_layer_handle) = tracing_subscriber::reload::Layer::new(vec![]); + let (route_layer, route_layer_handle) = tracing_subscriber::reload::Layer::new(f()); + let route_layer: tracing_subscriber::reload::Layer<_, _> = route_layer; + let subscriber = tracing_subscriber::registry() + .with(route_layer) .with( tracing_subscriber::fmt::layer() .with_line_number(true) diff --git a/meilisearch/src/routes/logs.rs b/meilisearch/src/routes/logs.rs index 3201fc5b7..a20dac8bb 100644 --- a/meilisearch/src/routes/logs.rs +++ b/meilisearch/src/routes/logs.rs @@ -115,15 +115,15 @@ pub async fn get_logs( let (sender, receiver) = tokio::sync::mpsc::unbounded_channel(); - let subscriber = tracing_subscriber::registry().with( - tracing_subscriber::fmt::layer() - .with_line_number(true) - .with_writer(move || LogWriter { sender: sender.clone() }) - .with_span_events(tracing_subscriber::fmt::format::FmtSpan::ACTIVE) - .with_filter( - tracing_subscriber::filter::LevelFilter::from_str(&opt.level.to_string()).unwrap(), - ), - ); + let layer = tracing_subscriber::fmt::layer() + .with_line_number(true) + .with_writer(move || LogWriter { sender: sender.clone() }) + .with_span_events(tracing_subscriber::fmt::format::FmtSpan::ACTIVE) + .with_filter( + tracing_subscriber::filter::LevelFilter::from_str(&opt.level.to_string()).unwrap(), + ); + + let subscriber = tracing_subscriber::registry().with(layer); // .with( // layer.with_filter( // tracing_subscriber::filter::Targets::new()