From 7e215c691b2e748af095bf05e34ec38f06c41c49 Mon Sep 17 00:00:00 2001 From: asonix Date: Thu, 28 Dec 2023 12:40:59 -0600 Subject: [PATCH] Support RUST_LOG --- src/config.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/config.rs b/src/config.rs index 2745685..d5ec99d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -73,6 +73,18 @@ pub(crate) fn configure_without_clap, 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 { 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")