pub trait FormatTime {
// Required methods
fn format_time(&self, w: &mut impl Write) -> Result;
fn style_timestamp(
&self,
ansi: bool,
elapsed: Duration,
w: &mut impl Write,
) -> Result;
}
Expand description
A type that can measure and format the current time.
This trait is used by HierarchicalLayer to include a timestamp with each Event when it is logged.
Notable default implementations of this trait are [LocalDateTime] and ()
.
The former prints the current time as reported by time’s OffsetDateTime
(note that it requires a time
feature to be enabled and may panic!
make sure to check out the docs for the [LocalDateTime]),
and the latter does not print the current time at all.
Inspired by the FormatTime trait from tracing-subscriber.
Required Methods§
fn format_time(&self, w: &mut impl Write) -> Result
fn style_timestamp( &self, ansi: bool, elapsed: Duration, w: &mut impl Write, ) -> Result
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl FormatTime for ()
Default do-nothing time formatter.
impl FormatTime for ()
Default do-nothing time formatter.