From 727aa8cf735097e09cb824db4ee71f106456848b Mon Sep 17 00:00:00 2001 From: Rain Date: Sat, 26 Oct 2024 18:12:32 -0700 Subject: [PATCH] [cargo-nextest] show other fields for debug and trace logs For these logs, don't hide non-message fields since they're quite useful for debugging. --- cargo-nextest/src/output.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cargo-nextest/src/output.rs b/cargo-nextest/src/output.rs index 54ca1acd498..b06f98eeeef 100644 --- a/cargo-nextest/src/output.rs +++ b/cargo-nextest/src/output.rs @@ -165,6 +165,8 @@ where let mut visitor = MessageVisitor { writer: &mut writer, + // Show other fields for debug or trace output. + show_other: *metadata.level() >= Level::DEBUG, error: None, }; @@ -182,6 +184,7 @@ static MESSAGE_FIELD: &str = "message"; struct MessageVisitor<'writer, 'a> { writer: &'a mut format::Writer<'writer>, + show_other: bool, error: Option, } @@ -191,6 +194,10 @@ impl<'writer, 'a> Visit for MessageVisitor<'writer, 'a> { if let Err(error) = write!(self.writer, "{:?}", value) { self.error = Some(error); } + } else if self.show_other { + if let Err(error) = write!(self.writer, "; {} = {:?}", field.name(), value) { + self.error = Some(error); + } } } } @@ -224,9 +231,14 @@ impl Color { cfg_if::cfg_if! { if #[cfg(feature = "experimental-tokio-console")] { let console_layer = nextest_runner::console::spawn(); - tracing_subscriber::registry().with(layer).with(console_layer).init(); + tracing_subscriber::registry() + .with(layer) + .with(console_layer) + .init(); } else { - tracing_subscriber::registry().with(layer).init(); + tracing_subscriber::registry() + .with(layer) + .init(); } }