pub trait FormatTime {
    // Required method
    fn format_time(&self, w: &mut Writer<'_>) -> Result<(), Error>;
}
Expand description

A type that can measure and format the current time.

This trait is used by Format to include a timestamp with each Event when it is logged.

Notable default implementations of this trait are SystemTime and (). The former prints the current time as reported by std::time::SystemTime, and the latter does not print the current time at all. FormatTime is also automatically implemented for any function pointer with the appropriate signature.

The full list of provided implementations can be found in time.

Required Methods§

source

fn format_time(&self, w: &mut Writer<'_>) -> Result<(), Error>

Measure and write out the current time.

When format_time is called, implementors should get the current time using their desired mechanism, and write it out to the given fmt::Write. Implementors must insert a trailing space themselves if they wish to separate the time from subsequent log message text.

Implementations on Foreign Types§

source§

impl FormatTime for fn(_: &mut Writer<'_>) -> Result<(), Error>

source§

fn format_time(&self, w: &mut Writer<'_>) -> Result<(), Error>

source§

impl FormatTime for ()

source§

fn format_time(&self, _: &mut Writer<'_>) -> Result<(), Error>

source§

impl<'a, F> FormatTime for &'a F
where F: FormatTime,

source§

fn format_time(&self, w: &mut Writer<'_>) -> Result<(), Error>

Implementors§