From c23a457e72abe608715ac76f076f47dc42af07a5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 20:31:44 +0200 Subject: Merging upstream version 1.74.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/tracing-tree/src/format.rs | 4 +++- vendor/tracing-tree/src/lib.rs | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'vendor/tracing-tree/src') diff --git a/vendor/tracing-tree/src/format.rs b/vendor/tracing-tree/src/format.rs index 895c04be2..aa56178be 100644 --- a/vendor/tracing-tree/src/format.rs +++ b/vendor/tracing-tree/src/format.rs @@ -167,11 +167,12 @@ impl Buffers { } pub(crate) fn indent_current(&mut self, indent: usize, config: &Config, style: SpanMode) { - self.current_buf.push('\n'); let prefix = config.prefix(); // Render something when wraparound occurs so the user is aware of it if config.indent_lines { + self.current_buf.push('\n'); + match style { SpanMode::Close { .. } | SpanMode::PostClose => { if indent > 0 && (indent + 1) % config.wraparound == 0 { @@ -417,6 +418,7 @@ fn indent_block( let indent_str = String::from(" ").repeat(indent_spaces); for line in lines { buf.push_str(prefix); + buf.push(' '); buf.push_str(&indent_str); buf.push_str(line); buf.push('\n'); diff --git a/vendor/tracing-tree/src/lib.rs b/vendor/tracing-tree/src/lib.rs index ec3467493..d171c7608 100644 --- a/vendor/tracing-tree/src/lib.rs +++ b/vendor/tracing-tree/src/lib.rs @@ -4,6 +4,7 @@ pub mod time; use crate::time::FormatTime; use format::{Buffers, ColorLevel, Config, FmtEvent, SpanMode}; +use is_terminal::IsTerminal; use nu_ansi_term::{Color, Style}; use std::{ fmt::{self, Write as _}, @@ -65,7 +66,7 @@ impl Default for HierarchicalLayer { impl HierarchicalLayer io::Stderr> { pub fn new(indent_amount: usize) -> Self { - let ansi = atty::is(atty::Stream::Stderr); + let ansi = io::stderr().is_terminal(); let config = Config { ansi, indent_amount, @@ -364,11 +365,21 @@ where }; if let Some(start) = start { let elapsed = start.elapsed(); + let millis = elapsed.as_millis(); + let secs = elapsed.as_secs(); + let (n, unit) = if millis < 1000 { + (millis as _, "ms") + } else if secs < 60 { + (secs, "s ") + } else { + (secs / 60, "m ") + }; + let n = format!("{n:>3}"); write!( &mut event_buf, "{timestamp}{unit} ", - timestamp = self.styled(Style::new().dimmed(), elapsed.as_millis().to_string()), - unit = self.styled(Style::new().dimmed(), "ms"), + timestamp = self.styled(Style::new().dimmed(), n), + unit = self.styled(Style::new().dimmed(), unit), ) .expect("Unable to write to buffer"); } -- cgit v1.2.3