diff --git a/src/fmt/mod.rs b/src/fmt/mod.rs index 6d9c8d16..c0d79094 100644 --- a/src/fmt/mod.rs +++ b/src/fmt/mod.rs @@ -247,8 +247,8 @@ impl<'a> DefaultFormat<'a> { self.write_timestamp()?; self.write_level(record)?; self.write_module_path(record)?; - self.write_kv(record)?; self.write_target(record)?; + self.write_kv(record)?; self.finish_header()?; self.write_args(record) @@ -714,4 +714,38 @@ mod tests { #[cfg(feature = "kv_unstable")] assert_eq!("[INFO a=1 b=2] log\nmessage\n", written); } + + #[cfg(feature = "kv_unstable")] + #[test] + fn format_kv_full() { + let kvs = &[("a", 1u32), ("b", 2u32)][..]; + let mut f = formatter(); + let record = Record::builder() + .args(format_args!("log\nmessage")) + .level(Level::Info) + .module_path(Some("test::path")) + .target("target") + .file(Some("test.rs")) + .line(Some(42)) + .key_values(&kvs) + .build(); + + let written = write_record( + record, + DefaultFormat { + timestamp: None, + module_path: true, + target: true, + level: true, + key_values: true, + written_header_value: false, + indent: None, + suffix: "\n", + buf: &mut f, + }, + ); + + #[cfg(feature = "kv_unstable")] + assert_eq!("[INFO test::path target a=1 b=2] log\nmessage\n", written); + } }