diff --git a/tracing-subscriber/src/fmt/format/mod.rs b/tracing-subscriber/src/fmt/format/mod.rs index 31ca7676a..6ea1891bc 100644 --- a/tracing-subscriber/src/fmt/format/mod.rs +++ b/tracing-subscriber/src/fmt/format/mod.rs @@ -1238,12 +1238,20 @@ impl field::Visit for DefaultVisitor<'_> { return; } + let name = field.name(); + + // Skip fields that are actually log metadata that have already been handled + #[cfg(feature = "tracing-log")] + if name.starts_with("log.") { + debug_assert_eq!(self.result, Ok(())); // no need to update self.result + return; + } + + // emit separating spaces if needed self.maybe_pad(); - self.result = match field.name() { + + self.result = match name { "message" => write!(self.writer, "{:?}", value), - // Skip fields that are actually log metadata that have already been handled - #[cfg(feature = "tracing-log")] - name if name.starts_with("log.") => Ok(()), name if name.starts_with("r#") => write!( self.writer, "{}{}{:?}",