Skip to content

Commit

Permalink
Changed the order of the field in json log output (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
freakmaxi committed Dec 17, 2023
1 parent 97c1347 commit ebb9123
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/encode/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ impl JsonEncoder {
let thread = thread::current();
let message = Message {
time: time.format_with_items(Some(Item::Fixed(Fixed::RFC3339)).into_iter()),
message: record.args(),
level: record.level(),
message: record.args(),
module_path: record.module_path(),
file: record.file(),
line: record.line(),
Expand All @@ -93,6 +93,7 @@ impl Encode for JsonEncoder {
struct Message<'a> {
#[serde(serialize_with = "ser_display")]
time: DelayedFormat<option::IntoIter<Item<'a>>>,
level: Level,
#[serde(serialize_with = "ser_display")]
message: &'a fmt::Arguments<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -101,7 +102,6 @@ struct Message<'a> {
file: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
line: Option<u32>,
level: Level,
target: &'a str,
thread: Option<&'a str>,
thread_id: usize,
Expand Down Expand Up @@ -206,15 +206,15 @@ mod test {
.unwrap();

let expected = format!(
"{{\"time\":\"{}\",\"message\":\"{}\",\"module_path\":\"{}\",\
\"file\":\"{}\",\"line\":{},\"level\":\"{}\",\"target\":\"{}\",\
"{{\"time\":\"{}\",\"level\":\"{}\",\"message\":\"{}\",\"module_path\":\"{}\",\
\"file\":\"{}\",\"line\":{},\"target\":\"{}\",\
\"thread\":\"{}\",\"thread_id\":{},\"mdc\":{{\"foo\":\"bar\"}}}}",
time.to_rfc3339(),
level,
message,
module_path,
file,
line,
level,
target,
thread,
thread_id::get(),
Expand Down

0 comments on commit ebb9123

Please sign in to comment.