diff --git a/crates/uv-settings/src/lib.rs b/crates/uv-settings/src/lib.rs index 49eb5927c..8f01087d1 100644 --- a/crates/uv-settings/src/lib.rs +++ b/crates/uv-settings/src/lib.rs @@ -571,6 +571,7 @@ pub struct EnvironmentOptions { pub python_install_bin: Option, pub python_install_registry: Option, pub install_mirrors: PythonInstallMirrors, + pub log_context: Option, } impl EnvironmentOptions { @@ -592,6 +593,7 @@ impl EnvironmentOptions { EnvVars::UV_PYTHON_DOWNLOADS_JSON_URL, )?, }, + log_context: parse_boolish_environment_variable(EnvVars::UV_LOG_CONTEXT)?, }) } } diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index 3da0606c2..ddb03c4bc 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -367,6 +367,7 @@ async fn run(mut cli: Cli) -> Result { }, durations_layer, globals.color, + environment.log_context.unwrap_or_default(), )?; // Configure the `Printer`, which controls user-facing output in the CLI. diff --git a/crates/uv/src/logging.rs b/crates/uv/src/logging.rs index 9654e3ab2..1520b4dbc 100644 --- a/crates/uv/src/logging.rs +++ b/crates/uv/src/logging.rs @@ -14,6 +14,7 @@ use tracing_tree::time::Uptime; use uv_cli::ColorChoice; use uv_logging::UvFormat; +#[cfg(feature = "tracing-durations-export")] use uv_static::EnvVars; #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] @@ -35,6 +36,7 @@ pub(crate) fn setup_logging( level: Level, durations_layer: Option + Send + Sync>, color: ColorChoice, + detailed_logging: bool, ) -> anyhow::Result<()> { // We use directives here to ensure `RUST_LOG` can override them let default_directive = match level { @@ -87,7 +89,6 @@ pub(crate) fn setup_logging( }; let writer = std::sync::Mutex::new(anstream::AutoStream::new(std::io::stderr(), color_choice)); - let detailed_logging = std::env::var(EnvVars::UV_LOG_CONTEXT).is_ok(); if detailed_logging { // Regardless of the tracing level, include the uptime and target for each message. tracing_subscriber::registry()