-
Notifications
You must be signed in to change notification settings - Fork 595
Description
Only similar issue I found is closed #1339.
The RFC3339 does not require microsecond precision!
- Why not make
write_rfc3339public so we can reuse it? - Or, add a variant:
Fixed::RFC3339Secs(SecondsFormat)that passesSecondsFormattowrite_rfc3339internally (that would actually be really easy to do)?
I want to offer easier seconds formatting for better_tracing to make configuring time easier. The only option from the upstream tracing_subscriber is to use a string to format, much like #1339 suggests.
It's kind of infuriating to have to re-invent the wheel and look up the correct strftime format for the whole thing just to change the number of digits on seconds. In development, who needs microseconds precision 90% of the time?
I'm making public and adding a variant to ChronoFmtType:
#[derive(Debug, Clone, Eq, PartialEq, Default)]
pub enum ChronoFmtType {
/// Format according to the RFC 3339 convention.
#[default]
Rfc3339,
/// Format with [`SecondsFormat`] seconds format according to the RFC 3339 convention.
Rfc3339Secs(SecondsFormat),
/// Format according to multiple `chrono` format [Items][`Item`].
Items(Vec<Item<'static>>),
/// Format according to a custom format string.
Custom(String),
}and noticed that rfc3339 is just:
ChronoFmtType::Rfc3339 => {
write!(
w,
"{}",
t.format_with_items(core::iter::once(Item::Fixed(Fixed::RFC3339)))
)
}
But then Fixed::RFC3339 uses write_rfc3339 internally.
So why not Fixed::RFC3339Secs(SecondsFormat) or allow us access to write_rfc3339? Because the feature is already there, it's just not public.