Skip to content

Commit

Permalink
subscriber: add inherent bold method (review)
Browse files Browse the repository at this point in the history
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
katelyn martin and hawkw committed Mar 9, 2021
1 parent f481413 commit 3c6b46c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tracing-subscriber/src/fmt/format/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ impl<'a> PrettyVisitor<'a> {
self.result = write!(self.writer, ", ");
}
}

fn bold(&self) -> Style {
if self.ansi {
self.style.bold()
} else {
Style::new()
}
}
}

impl<'a> field::Visit for PrettyVisitor<'a> {
Expand All @@ -285,11 +293,7 @@ impl<'a> field::Visit for PrettyVisitor<'a> {

fn record_error(&mut self, field: &Field, value: &(dyn std::error::Error + 'static)) {
if let Some(source) = value.source() {
let bold = if self.ansi {
self.style.bold()
} else {
Style::new()
};
let bold = self.bold();
self.record_debug(
field,
&format_args!(
Expand All @@ -310,11 +314,7 @@ impl<'a> field::Visit for PrettyVisitor<'a> {
if self.result.is_err() {
return;
}
let bold = if self.ansi {
self.style.bold()
} else {
Style::new()
};
let bold = self.bold();
self.maybe_pad();
self.result = match field.name() {
"message" => write!(self.writer, "{}{:?}", self.style.prefix(), value,),
Expand Down

0 comments on commit 3c6b46c

Please sign in to comment.