Trait tracing_tree::time::FormatTime

source ·
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§

source

fn format_time(&self, w: &mut impl Write) -> Result

source

fn style_timestamp( &self, ansi: bool, elapsed: Duration, w: &mut impl Write, ) -> Result

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl FormatTime for ()

Default do-nothing time formatter.

source§

fn format_time(&self, _w: &mut impl Write) -> Result

source§

fn style_timestamp( &self, _ansi: bool, _elapsed: Duration, _w: &mut impl Write, ) -> Result

source§

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

source§

fn format_time(&self, w: &mut impl Write) -> Result

source§

fn style_timestamp( &self, ansi: bool, duration: Duration, w: &mut impl Write, ) -> Result

Implementors§