Skip to content

Commit

Permalink
[cargo-nextest] show other fields for debug and trace logs
Browse files Browse the repository at this point in the history
For these logs, don't hide non-message fields since they're quite useful for
debugging.
  • Loading branch information
sunshowers committed Nov 28, 2024
1 parent 1aaeeae commit 727aa8c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cargo-nextest/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -182,6 +184,7 @@ static MESSAGE_FIELD: &str = "message";

struct MessageVisitor<'writer, 'a> {
writer: &'a mut format::Writer<'writer>,
show_other: bool,
error: Option<fmt::Error>,
}

Expand All @@ -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);
}
}
}
}
Expand Down Expand Up @@ -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();
}
}

Expand Down

0 comments on commit 727aa8c

Please sign in to comment.