Skip to content

Commit f079f2d

Browse files
committed
subscriber: don't print curly braces on spans with no fields
Previously, when `tracing-subscriber`'s `fmt` module printed span contexts, curly braces were only added around a span's fields. When we replaced the previous implementation with the new `fmt::Layer`, this behavior was lost, and empty curly braces were added to spans without fields. This commit fixes this by putting back the `if` conditional that used to guard the printing of span fields. Signed-off-by: Eliza Weisman <[email protected]>
1 parent 506a482 commit f079f2d

File tree

1 file changed

+4
-1
lines changed
  • tracing-subscriber/src/fmt/format

1 file changed

+4
-1
lines changed

tracing-subscriber/src/fmt/format/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,10 @@ where
576576
let fields = &ext
577577
.get::<FormattedFields<N>>()
578578
.expect("Unable to find FormattedFields in extensions; this is a bug");
579-
write!(f, "{}{}{}:", bold.paint("{"), fields, bold.paint("}"))
579+
if !fields.is_empty() {
580+
write!(f, "{}{}{}", bold.paint("{"), fields, bold.paint("}"))?;
581+
}
582+
f.pad(":")
580583
})?;
581584

582585
if seen {

0 commit comments

Comments
 (0)