use crate::{tracing_init, TracingConfig};
pub fn log_init(rust_log: Option<&str>) {
let config = TracingConfig {
#[cfg(feature = "full")]
otlp: None,
service_name: String::new(),
no_log_to_stdout: false,
log_to_file: None,
#[cfg(not(target_os = "windows"))]
log_to_syslog: false,
rust_log: rust_log
.or(option_env!("RUST_LOG"))
.map(std::borrow::ToOwned::to_owned),
with_ansi_colors: false,
};
tracing_init(&config);
}
#[cfg(test)]
mod tests {
use tracing::{debug, info, trace};
use super::*;
#[test]
fn test_log_init() {
log_init(Some("debug"));
info!("This is an INFO test log message");
debug!("This is a DEBUG test log message");
debug!("RUST_LOG: {:?}", std::env::var("RUST_LOG"));
trace!("This is a TRACE test log message");
}
}