From c1fc9aa46ffb202d8bcecd346ca9361dffd18fe7 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Tue, 8 Apr 2025 18:11:49 +0200 Subject: [PATCH] Log thread ID and name in debug mode --- backend/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/main.rs b/backend/src/main.rs index a4e0e92..3462b8f 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -84,9 +84,15 @@ impl axum::response::IntoResponse for AppError { #[cfg(debug_assertions)] const TRACING_LEVEL: tracing::Level = tracing::Level::DEBUG; +#[cfg(debug_assertions)] +const TRACING_DISPLAY_THREAD: bool = true; + #[cfg(not(debug_assertions))] const TRACING_LEVEL: tracing::Level = tracing::Level::INFO; +#[cfg(not(debug_assertions))] +const TRACING_DISPLAY_THREAD: bool = false; + #[derive(Debug, Clone)] struct Context { user: Option, @@ -99,6 +105,8 @@ struct Context { async fn main() { tracing_subscriber::fmt() .with_max_level(TRACING_LEVEL) + .with_thread_ids(TRACING_DISPLAY_THREAD) + .with_thread_names(TRACING_DISPLAY_THREAD) .init(); if !process_args().await {