Log thread ID and name in debug mode

This commit is contained in:
Greg Burri 2025-04-08 18:11:49 +02:00
parent 24aa046f8c
commit c1fc9aa46f

View file

@ -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<model::User>,
@ -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 {