pub struct TimeFormat { /* private fields */ }
Expand description
The style of timestamp to be formatted for tracing events.
Format strings are used by jiff::fmt::strtime
, and local timezone handling is
provided by the jiff
crate.
Implementations§
Source§impl TimeFormat
impl TimeFormat
Sourcepub const LOCAL_FORMAT: &'static str = "[%Y-%m-%dT%H:%M:%S%z]"
pub const LOCAL_FORMAT: &'static str = "[%Y-%m-%dT%H:%M:%S%z]"
RFC 3339 timestamp enclosed in square brackets, with offset.
Sourcepub const UTC_FORMAT: &'static str = "[%Y-%m-%dT%H:%M:%SZ]"
pub const UTC_FORMAT: &'static str = "[%Y-%m-%dT%H:%M:%SZ]"
RFC 3339 timestamp enclosed in square brackets, with UTC (using ‘Z’ for the timezone instead of ‘+0000’)
Sourcepub const fn local() -> Self
pub const fn local() -> Self
Render a timestamp in the local timezone using the default format.
Sourcepub fn local_custom(format: impl Into<String>) -> Self
pub fn local_custom(format: impl Into<String>) -> Self
Render a timestamp in the local timezone using a custom format.
Panics: When debug_assertions
are enabled, the format string is validated to ensure
that no unknown %
fields are present. In release mode, formatting the timestamp fails and
tracing-subscriber will emit “Unable to format the following event” messages.
Sourcepub fn utc_custom(format: impl Into<String>) -> Self
pub fn utc_custom(format: impl Into<String>) -> Self
Render a timestamp in UTC using a custom format.
Panics: When debug_assertions
are enabled, the format string is validated to ensure
that no unknown %
fields are present. In release mode, formatting the timestamp fails and
tracing-subscriber will emit “Unable to format the following event” messages.
Sourcepub fn render(&self, ts: Timestamp) -> impl Display + '_
pub fn render(&self, ts: Timestamp) -> impl Display + '_
Get a Display
-able object of this format applied to a Timestamp
.
Sourcepub fn render_now(&self) -> impl Display + '_
pub fn render_now(&self) -> impl Display + '_
Render the current system time in this format
Trait Implementations§
Source§impl Clone for TimeFormat
impl Clone for TimeFormat
Source§fn clone(&self) -> TimeFormat
fn clone(&self) -> TimeFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more