/// 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`]. /// /// [`time`]: self pubtrait FormatTime { /// 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. fn format_time(&self, w: &mut Writer<'_>) -> fmt::Result;
}
/// Returns a new `SystemTime` timestamp provider. /// /// This can then be configured further to determine how timestamps should be /// configured. /// /// This is equivalent to calling /// ```rust /// # fn timer() -> tracing_subscriber::fmt::time::SystemTime { /// tracing_subscriber::fmt::time::SystemTime::default() /// # } /// ``` pubfn time() -> SystemTime {
SystemTime
}
/// Returns a new `Uptime` timestamp provider. /// /// With this timer, timestamps will be formatted with the amount of time /// elapsed since the timestamp provider was constructed. /// /// This can then be configured further to determine how timestamps should be /// configured. /// /// This is equivalent to calling /// ```rust /// # fn timer() -> tracing_subscriber::fmt::time::Uptime { /// tracing_subscriber::fmt::time::Uptime::default() /// # } /// ``` pubfn uptime() -> Uptime {
Uptime::default()
}
impl<F> FormatTime for &F where
F: FormatTime,
{ fn format_time(&self, w: &mut Writer<'_>) -> fmt::Result {
(*self).format_time(w)
}
}
/// Retrieve and print the current wall-clock time. #[derive(Debug, Clone, Copy, Eq, PartialEq, Default)] pubstruct SystemTime;
/// Retrieve and print the relative elapsed wall-clock time since an epoch. /// /// The `Default` implementation for `Uptime` makes the epoch the current time. #[derive(Debug, Clone, Copy, Eq, PartialEq)] pubstruct Uptime {
epoch: Instant,
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.