- updated: logging setup to allow extra crates to be passed in for logging

This commit is contained in:
2025-03-20 22:50:59 -04:00
parent 6a2711bdc1
commit b9ebdd7080

View File

@@ -2,9 +2,16 @@ use std::env;
use tracing::{debug, error, info, trace, warn};
use tracing_subscriber::EnvFilter;
pub fn setup_logging(app_name: &str) {
pub fn setup_logging(app_name: &str, additional_crates: &[&str]) {
let log_level = env::var("LOG_LEVEL").unwrap_or_else(|_| "info".to_string());
let filter = EnvFilter::try_new(format!("{app_name}={log_level},utils={log_level}"))
let mut filter_string = format!("{app_name}={log_level},utils={log_level}");
for (crate_name) in additional_crates {
filter_string.push(',');
filter_string.push_str(&format!("{crate_name}={log_level}"));
}
let filter = EnvFilter::try_new(filter_string)
.unwrap_or_else(|_| EnvFilter::new(format!("{app_name}=info,utils=info")));
tracing_subscriber::fmt()