server: Add a way to print raw logs
Some checks failed
Rust / pre_job (push) Has been cancelled
Rust / cargo test (push) Has been cancelled
Rust / cargo clippy (push) Has been cancelled
Rust / cargo fmt (push) Has been cancelled
Rust / Code coverage (push) Has been cancelled

If the variable LLDAP_RAW_LOG is set, the logs will be both formatted with tracing_forest and printed raw
This commit is contained in:
Valentin Tolmer 2024-10-10 21:07:36 +02:00 committed by nitnelave
parent dcb45d4f6b
commit 56eee6908e

View file

@ -3,6 +3,7 @@ use actix_web::{
dev::{ServiceRequest, ServiceResponse},
Error,
};
use std::env;
use tracing::{debug, error, Span};
use tracing_actix_web::RootSpanBuilder;
use tracing_subscriber::{filter::EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
@ -42,10 +43,14 @@ pub fn init(config: &Configuration) -> anyhow::Result<()> {
"sqlx=warn,reqwest=warn,info"
})
});
tracing_subscriber::registry()
let registry = tracing_subscriber::registry()
.with(env_filter)
.with(tracing_forest::ForestLayer::default())
.init();
.with(tracing_forest::ForestLayer::default());
if env::var("LLDAP_RAW_LOG").is_ok() {
registry.with(tracing_subscriber::fmt::layer()).init();
} else {
registry.init();
}
Ok(())
}