Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,15 @@ fn spawn_logline(commands: &mut Commands, parent: Entity, event: &LogEvent) -> E
TextSpan::new(
event
.timestamp
.format(&iso8601::Iso8601::<{ iso8601_with_two_digit_secs() }> {})
.format(&iso8601::Iso8601::<
{
iso8601::Config::DEFAULT
.set_time_precision(iso8601::TimePrecision::Second {
decimal_digits: Some(NonZero::new(2).unwrap()),
})
.encode()
},
> {})
.unwrap_or("timestamp error".to_string()),
),
TextFont::from_font_size(LOG_LINE_FONT_SIZE),
Expand Down Expand Up @@ -586,18 +594,3 @@ fn on_level_filter_chip(
}
}
}

/// ISO 8601 Config with two decimal digits for seconds.
const fn iso8601_with_two_digit_secs() -> u128 {
// This is a hack to get around .unwrap() not being stable as a const fn
const TWO: NonZero<u8> = match NonZero::new(2) {
Some(two) => two,
None => unreachable!(),
};

iso8601::Config::DEFAULT
.set_time_precision(iso8601::TimePrecision::Second {
decimal_digits: Some(TWO),
})
.encode()
}
Loading