init commit

This commit is contained in:
Tamo 2024-01-29 13:36:10 +01:00 committed by Louis Dureuil
parent f76cc0806e
commit 50f84d43f5
No known key found for this signature in database
2 changed files with 18 additions and 9 deletions

View File

@ -27,6 +27,10 @@ static ALLOC: MiMalloc = MiMalloc;
#[global_allocator] #[global_allocator]
static ALLOC: stats_alloc::StatsAlloc<MiMalloc> = stats_alloc::StatsAlloc::new(MiMalloc); static ALLOC: stats_alloc::StatsAlloc<MiMalloc> = stats_alloc::StatsAlloc::new(MiMalloc);
fn f<S: Sized>() -> Option<Box<dyn Layer<S>>> {
None
}
/// does all the setup before meilisearch is launched /// does all the setup before meilisearch is launched
fn setup(opt: &Opt) -> anyhow::Result<()> { fn setup(opt: &Opt) -> anyhow::Result<()> {
let now = time::OffsetDateTime::now_utc(); let now = time::OffsetDateTime::now_utc();
@ -40,7 +44,12 @@ fn setup(opt: &Opt) -> anyhow::Result<()> {
#[cfg(feature = "stats_alloc")] #[cfg(feature = "stats_alloc")]
let (mut trace, layer) = tracing_trace::Trace::with_stats_alloc(file, &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() let subscriber = tracing_subscriber::registry()
.with(route_layer)
.with( .with(
tracing_subscriber::fmt::layer() tracing_subscriber::fmt::layer()
.with_line_number(true) .with_line_number(true)

View File

@ -115,15 +115,15 @@ pub async fn get_logs(
let (sender, receiver) = tokio::sync::mpsc::unbounded_channel(); let (sender, receiver) = tokio::sync::mpsc::unbounded_channel();
let subscriber = tracing_subscriber::registry().with( let layer = tracing_subscriber::fmt::layer()
tracing_subscriber::fmt::layer()
.with_line_number(true) .with_line_number(true)
.with_writer(move || LogWriter { sender: sender.clone() }) .with_writer(move || LogWriter { sender: sender.clone() })
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::ACTIVE) .with_span_events(tracing_subscriber::fmt::format::FmtSpan::ACTIVE)
.with_filter( .with_filter(
tracing_subscriber::filter::LevelFilter::from_str(&opt.level.to_string()).unwrap(), tracing_subscriber::filter::LevelFilter::from_str(&opt.level.to_string()).unwrap(),
),
); );
let subscriber = tracing_subscriber::registry().with(layer);
// .with( // .with(
// layer.with_filter( // layer.with_filter(
// tracing_subscriber::filter::Targets::new() // tracing_subscriber::filter::Targets::new()