Skip to content

Commit 4b73642

Browse files
committed
refactor(fmt): Make DefaultFormats name more specific
1 parent 916d376 commit 4b73642

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/fmt/mod.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub(crate) type FormatFn = Box<dyn RecordFormat + Sync + Send>;
228228

229229
#[derive(Default)]
230230
pub(crate) struct Builder {
231-
pub(crate) default_format: DefaultFormat,
231+
pub(crate) default_format: ConfigurableFormat,
232232
pub(crate) custom_format: Option<FormatFn>,
233233
built: bool,
234234
}
@@ -290,7 +290,7 @@ type StyledValue<T> = T;
290290
/// The default format.
291291
///
292292
/// This format needs to work with any combination of crate features.
293-
pub(crate) struct DefaultFormat {
293+
pub(crate) struct ConfigurableFormat {
294294
pub(crate) timestamp: Option<TimestampPrecision>,
295295
pub(crate) module_path: bool,
296296
pub(crate) target: bool,
@@ -303,7 +303,7 @@ pub(crate) struct DefaultFormat {
303303
pub(crate) kv_format: Option<Box<KvFormatFn>>,
304304
}
305305

306-
impl DefaultFormat {
306+
impl ConfigurableFormat {
307307
/// Whether or not to write the level in the default format.
308308
pub(crate) fn level(&mut self, write: bool) -> &mut Self {
309309
self.level = write;
@@ -375,7 +375,7 @@ impl DefaultFormat {
375375
}
376376
}
377377

378-
impl Default for DefaultFormat {
378+
impl Default for ConfigurableFormat {
379379
fn default() -> Self {
380380
Self {
381381
timestamp: Some(Default::default()),
@@ -392,9 +392,9 @@ impl Default for DefaultFormat {
392392
}
393393
}
394394

395-
impl RecordFormat for DefaultFormat {
395+
impl RecordFormat for ConfigurableFormat {
396396
fn format(&self, formatter: &mut Formatter, record: &Record<'_>) -> io::Result<()> {
397-
let fmt = DefaultFormatWriter {
397+
let fmt = ConfigurableFormatWriter {
398398
format: self,
399399
buf: formatter,
400400
written_header_value: false,
@@ -407,13 +407,13 @@ impl RecordFormat for DefaultFormat {
407407
/// The default format.
408408
///
409409
/// This format needs to work with any combination of crate features.
410-
struct DefaultFormatWriter<'a> {
411-
format: &'a DefaultFormat,
410+
struct ConfigurableFormatWriter<'a> {
411+
format: &'a ConfigurableFormat,
412412
buf: &'a mut Formatter,
413413
written_header_value: bool,
414414
}
415415

416-
impl DefaultFormatWriter<'_> {
416+
impl ConfigurableFormatWriter<'_> {
417417
fn write(mut self, record: &Record<'_>) -> io::Result<()> {
418418
self.write_timestamp()?;
419419
self.write_level(record)?;
@@ -567,7 +567,7 @@ impl DefaultFormatWriter<'_> {
567567
// Create a wrapper around the buffer only if we have to actually indent the message
568568

569569
struct IndentWrapper<'a, 'b> {
570-
fmt: &'a mut DefaultFormatWriter<'b>,
570+
fmt: &'a mut ConfigurableFormatWriter<'b>,
571571
indent_count: usize,
572572
}
573573

@@ -627,7 +627,7 @@ mod tests {
627627

628628
use log::{Level, Record};
629629

630-
fn write_record(record: Record<'_>, fmt: DefaultFormatWriter<'_>) -> String {
630+
fn write_record(record: Record<'_>, fmt: ConfigurableFormatWriter<'_>) -> String {
631631
let buf = fmt.buf.buf.clone();
632632

633633
fmt.write(&record).expect("failed to write record");
@@ -636,7 +636,7 @@ mod tests {
636636
String::from_utf8(buf.as_bytes().to_vec()).expect("failed to read record")
637637
}
638638

639-
fn write_target(target: &str, fmt: DefaultFormatWriter<'_>) -> String {
639+
fn write_target(target: &str, fmt: ConfigurableFormatWriter<'_>) -> String {
640640
write_record(
641641
Record::builder()
642642
.args(format_args!("log\nmessage"))
@@ -650,7 +650,7 @@ mod tests {
650650
)
651651
}
652652

653-
fn write(fmt: DefaultFormatWriter<'_>) -> String {
653+
fn write(fmt: ConfigurableFormatWriter<'_>) -> String {
654654
write_target("", fmt)
655655
}
656656

@@ -666,7 +666,7 @@ mod tests {
666666
fn format_with_header() {
667667
let mut f = formatter();
668668

669-
let written = write(DefaultFormatWriter {
669+
let written = write(ConfigurableFormatWriter {
670670
timestamp: None,
671671
module_path: true,
672672
target: false,
@@ -688,7 +688,7 @@ mod tests {
688688
fn format_no_header() {
689689
let mut f = formatter();
690690

691-
let written = write(DefaultFormatWriter {
691+
let written = write(ConfigurableFormatWriter {
692692
timestamp: None,
693693
module_path: false,
694694
target: false,
@@ -710,7 +710,7 @@ mod tests {
710710
fn format_indent_spaces() {
711711
let mut f = formatter();
712712

713-
let written = write(DefaultFormatWriter {
713+
let written = write(ConfigurableFormatWriter {
714714
timestamp: None,
715715
module_path: true,
716716
target: false,
@@ -732,7 +732,7 @@ mod tests {
732732
fn format_indent_zero_spaces() {
733733
let mut f = formatter();
734734

735-
let written = write(DefaultFormatWriter {
735+
let written = write(ConfigurableFormatWriter {
736736
timestamp: None,
737737
module_path: true,
738738
target: false,
@@ -754,7 +754,7 @@ mod tests {
754754
fn format_indent_spaces_no_header() {
755755
let mut f = formatter();
756756

757-
let written = write(DefaultFormatWriter {
757+
let written = write(ConfigurableFormatWriter {
758758
timestamp: None,
759759
module_path: false,
760760
target: false,
@@ -776,7 +776,7 @@ mod tests {
776776
fn format_suffix() {
777777
let mut f = formatter();
778778

779-
let written = write(DefaultFormatWriter {
779+
let written = write(ConfigurableFormatWriter {
780780
timestamp: None,
781781
module_path: false,
782782
target: false,
@@ -798,7 +798,7 @@ mod tests {
798798
fn format_suffix_with_indent() {
799799
let mut f = formatter();
800800

801-
let written = write(DefaultFormatWriter {
801+
let written = write(ConfigurableFormatWriter {
802802
timestamp: None,
803803
module_path: false,
804804
target: false,
@@ -822,7 +822,7 @@ mod tests {
822822

823823
let written = write_target(
824824
"target",
825-
DefaultFormatWriter {
825+
ConfigurableFormatWriter {
826826
timestamp: None,
827827
module_path: true,
828828
target: true,
@@ -845,7 +845,7 @@ mod tests {
845845
fn format_empty_target() {
846846
let mut f = formatter();
847847

848-
let written = write(DefaultFormatWriter {
848+
let written = write(ConfigurableFormatWriter {
849849
timestamp: None,
850850
module_path: true,
851851
target: true,
@@ -869,7 +869,7 @@ mod tests {
869869

870870
let written = write_target(
871871
"target",
872-
DefaultFormatWriter {
872+
ConfigurableFormatWriter {
873873
timestamp: None,
874874
module_path: true,
875875
target: false,
@@ -892,7 +892,7 @@ mod tests {
892892
fn format_with_source_file_and_line_number() {
893893
let mut f = formatter();
894894

895-
let written = write(DefaultFormatWriter {
895+
let written = write(ConfigurableFormatWriter {
896896
timestamp: None,
897897
module_path: false,
898898
target: false,
@@ -924,7 +924,7 @@ mod tests {
924924

925925
let written = write_record(
926926
record,
927-
DefaultFormatWriter {
927+
ConfigurableFormatWriter {
928928
timestamp: None,
929929
module_path: false,
930930
target: false,
@@ -959,7 +959,7 @@ mod tests {
959959

960960
let written = write_record(
961961
record,
962-
DefaultFormatWriter {
962+
ConfigurableFormatWriter {
963963
timestamp: None,
964964
module_path: true,
965965
target: true,

0 commit comments

Comments
 (0)