summaryrefslogtreecommitdiffstats
path: root/vendor/tracing-tree/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/tracing-tree/src
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tracing-tree/src')
-rw-r--r--vendor/tracing-tree/src/format.rs4
-rw-r--r--vendor/tracing-tree/src/lib.rs17
2 files changed, 17 insertions, 4 deletions
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<fn() -> 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");
}