Support RUST_LOG

This commit is contained in:
asonix 2023-12-28 12:40:59 -06:00
parent bfc2410552
commit 7e215c691b
1 changed files with 24 additions and 0 deletions

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)?), 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 let built = config
.add_source( .add_source(
config::Environment::with_prefix("PICTRS") config::Environment::with_prefix("PICTRS")
@ -109,6 +121,18 @@ pub(crate) fn configure() -> color_eyre::Result<PictRsConfiguration> {
config 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 let built = config
.add_source( .add_source(
config::Environment::with_prefix("PICTRS") config::Environment::with_prefix("PICTRS")