Support RUST_LOG

This commit is contained in:
asonix 2023-12-28 12:40:59 -06:00
parent bfc2410552
commit 7e215c691b

View file

@ -73,6 +73,18 @@ pub(crate) fn configure_without_clap<P: AsRef<Path>, T: serde::Serialize, Q: AsR
ConfigSource::Memory { values } => config.add_source(config::Config::try_from(&values)?),
};
let config = if let Ok(targets) = std::env::var("RUST_LOG") {
config.add_source(config::Config::try_from(&serde_json::json!({
"tracing": {
"logging": {
"targets": targets,
}
}
}))?)
} else {
config
};
let built = config
.add_source(
config::Environment::with_prefix("PICTRS")
@ -109,6 +121,18 @@ pub(crate) fn configure() -> color_eyre::Result<PictRsConfiguration> {
config
};
let config = if let Ok(targets) = std::env::var("RUST_LOG") {
config.add_source(config::Config::try_from(&serde_json::json!({
"tracing": {
"logging": {
"targets": targets,
}
}
}))?)
} else {
config
};
let built = config
.add_source(
config::Environment::with_prefix("PICTRS")