Skip to content

Commit c567fde

Browse files
committed
refactor(fmt): Pull out format logic
1 parent ce25c73 commit c567fde

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/fmt/mod.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,19 @@ pub(crate) struct ConfigurableFormat {
292292
pub(crate) kv_format: Option<Box<KvFormatFn>>,
293293
}
294294

295+
impl ConfigurableFormat {
296+
/// Format the [`Record`] as configured for outputting
297+
pub(crate) fn format(&self, formatter: &mut Formatter, record: &Record<'_>) -> io::Result<()> {
298+
let fmt = ConfigurableFormatWriter {
299+
format: self,
300+
buf: formatter,
301+
written_header_value: false,
302+
};
303+
304+
fmt.write(record)
305+
}
306+
}
307+
295308
impl ConfigurableFormat {
296309
/// Whether or not to write the level in the default format.
297310
pub(crate) fn level(&mut self, write: bool) -> &mut Self {
@@ -383,13 +396,7 @@ impl Default for ConfigurableFormat {
383396

384397
impl RecordFormat for ConfigurableFormat {
385398
fn format(&self, formatter: &mut Formatter, record: &Record<'_>) -> io::Result<()> {
386-
let fmt = ConfigurableFormatWriter {
387-
format: self,
388-
buf: formatter,
389-
written_header_value: false,
390-
};
391-
392-
fmt.write(record)
399+
self.format(formatter, record)
393400
}
394401
}
395402

0 commit comments

Comments
 (0)