mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Avoid rendering info log level (#13642)
We were previously rendering messages for the info level, carrying overhead in pubgrub which using `log::info!`. We avoid this by only configuring `LevelFilter::INFO` if the durations layer exists. I've confirmed that the default `Subscriber::max_level_hint` goes from `INFO` to `OFF` and the profile skips `Incompatibility::display`.
This commit is contained in:
parent
a6f8fa7e42
commit
6ab1d12480
2 changed files with 13 additions and 11 deletions
|
@ -347,9 +347,9 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
|
|||
|
||||
// Configure the `tracing` crate, which controls internal logging.
|
||||
#[cfg(feature = "tracing-durations-export")]
|
||||
let (duration_layer, _duration_guard) = logging::setup_duration()?;
|
||||
let (durations_layer, _duration_guard) = logging::setup_durations()?;
|
||||
#[cfg(not(feature = "tracing-durations-export"))]
|
||||
let duration_layer = None::<tracing_subscriber::layer::Identity>;
|
||||
let durations_layer = None::<tracing_subscriber::layer::Identity>;
|
||||
logging::setup_logging(
|
||||
match globals.verbose {
|
||||
0 => logging::Level::Off,
|
||||
|
@ -357,7 +357,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
|
|||
2 => logging::Level::TraceUv,
|
||||
3.. => logging::Level::TraceAll,
|
||||
},
|
||||
duration_layer,
|
||||
durations_layer,
|
||||
globals.color,
|
||||
)?;
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ where
|
|||
/// includes targets and timestamps, along with all `uv=debug` messages by default.
|
||||
pub(crate) fn setup_logging(
|
||||
level: Level,
|
||||
durations: impl Layer<Registry> + Send + Sync,
|
||||
durations_layer: Option<impl Layer<Registry> + Send + Sync>,
|
||||
color: ColorChoice,
|
||||
) -> anyhow::Result<()> {
|
||||
// We use directives here to ensure `RUST_LOG` can override them
|
||||
|
@ -137,12 +137,14 @@ pub(crate) fn setup_logging(
|
|||
}
|
||||
};
|
||||
|
||||
// Only record our own spans.
|
||||
let durations_layer = durations.with_filter(
|
||||
tracing_subscriber::filter::Targets::new()
|
||||
.with_target("", tracing::level_filters::LevelFilter::INFO),
|
||||
);
|
||||
|
||||
// Avoid setting the default log level to INFO
|
||||
let durations_layer = durations_layer.map(|durations_layer| {
|
||||
durations_layer.with_filter(
|
||||
// Only record our own spans
|
||||
tracing_subscriber::filter::Targets::new()
|
||||
.with_target("", tracing::level_filters::LevelFilter::INFO),
|
||||
)
|
||||
});
|
||||
let filter = EnvFilter::builder()
|
||||
.with_default_directive(default_directive)
|
||||
.from_env()
|
||||
|
@ -205,7 +207,7 @@ pub(crate) fn setup_logging(
|
|||
|
||||
/// Setup the `TRACING_DURATIONS_FILE` environment variable to enable tracing durations.
|
||||
#[cfg(feature = "tracing-durations-export")]
|
||||
pub(crate) fn setup_duration() -> anyhow::Result<(
|
||||
pub(crate) fn setup_durations() -> anyhow::Result<(
|
||||
Option<DurationsLayer<Registry>>,
|
||||
Option<DurationsLayerDropGuard>,
|
||||
)> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue