mirror of https://github.com/astral-sh/uv
Add UV_LOG_CONTEXT to EnvironmentOptions (#16031)
## Summary Add UV_LOG_CONTEXT to EnvironmentOptions Relates https://github.com/astral-sh/uv/issues/14720 ## Test Plan Tests with existing tests
This commit is contained in:
parent
372283c0cf
commit
1d76c5a365
|
|
@ -571,6 +571,7 @@ pub struct EnvironmentOptions {
|
||||||
pub python_install_bin: Option<bool>,
|
pub python_install_bin: Option<bool>,
|
||||||
pub python_install_registry: Option<bool>,
|
pub python_install_registry: Option<bool>,
|
||||||
pub install_mirrors: PythonInstallMirrors,
|
pub install_mirrors: PythonInstallMirrors,
|
||||||
|
pub log_context: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EnvironmentOptions {
|
impl EnvironmentOptions {
|
||||||
|
|
@ -592,6 +593,7 @@ impl EnvironmentOptions {
|
||||||
EnvVars::UV_PYTHON_DOWNLOADS_JSON_URL,
|
EnvVars::UV_PYTHON_DOWNLOADS_JSON_URL,
|
||||||
)?,
|
)?,
|
||||||
},
|
},
|
||||||
|
log_context: parse_boolish_environment_variable(EnvVars::UV_LOG_CONTEXT)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -367,6 +367,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
|
||||||
},
|
},
|
||||||
durations_layer,
|
durations_layer,
|
||||||
globals.color,
|
globals.color,
|
||||||
|
environment.log_context.unwrap_or_default(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Configure the `Printer`, which controls user-facing output in the CLI.
|
// Configure the `Printer`, which controls user-facing output in the CLI.
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ use tracing_tree::time::Uptime;
|
||||||
|
|
||||||
use uv_cli::ColorChoice;
|
use uv_cli::ColorChoice;
|
||||||
use uv_logging::UvFormat;
|
use uv_logging::UvFormat;
|
||||||
|
#[cfg(feature = "tracing-durations-export")]
|
||||||
use uv_static::EnvVars;
|
use uv_static::EnvVars;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|
@ -35,6 +36,7 @@ pub(crate) fn setup_logging(
|
||||||
level: Level,
|
level: Level,
|
||||||
durations_layer: Option<impl Layer<Registry> + Send + Sync>,
|
durations_layer: Option<impl Layer<Registry> + Send + Sync>,
|
||||||
color: ColorChoice,
|
color: ColorChoice,
|
||||||
|
detailed_logging: bool,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
// We use directives here to ensure `RUST_LOG` can override them
|
// We use directives here to ensure `RUST_LOG` can override them
|
||||||
let default_directive = match level {
|
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 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 {
|
if detailed_logging {
|
||||||
// Regardless of the tracing level, include the uptime and target for each message.
|
// Regardless of the tracing level, include the uptime and target for each message.
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue