Struct flexi_logger::DeferredNow
source · pub struct DeferredNow(/* private fields */);
Expand description
Deferred timestamp creation.
Is used to ensure that a log record that is sent to multiple outputs (in maybe different formats) always uses the same timestamp.
Implementations§
source§impl<'a> DeferredNow
impl<'a> DeferredNow
sourcepub fn now(&'a mut self) -> &'a DateTime<Local>
pub fn now(&'a mut self) -> &'a DateTime<Local>
Retrieve the timestamp for local time zone.
Requires mutability because the first caller will generate the timestamp.
sourcepub fn now_utc_owned(&'a mut self) -> DateTime<Utc>
pub fn now_utc_owned(&'a mut self) -> DateTime<Utc>
Retrieve the UTC timestamp.
Requires mutability because the first caller will generate the timestamp.
sourcepub fn format<'b>(
&'a mut self,
fmt: &'b str,
) -> DelayedFormat<StrftimeItems<'b>>
pub fn format<'b>( &'a mut self, fmt: &'b str, ) -> DelayedFormat<StrftimeItems<'b>>
Produces a preformatted object suitable for printing.
§Panics
Panics if fmt
has an inappropriate value.
sourcepub fn format_rfc3339(&mut self) -> String
pub fn format_rfc3339(&mut self) -> String
Prints itself in a format compliant with RFC 3339.
Example: 2021-04-29T13:14:15.678+01:00
We do not use the Z variant of RFC 3339, because it is often misinterpreted.
sourcepub fn force_utc()
pub fn force_utc()
Enforce the use of UTC rather than local time.
By default, flexi_logger
uses or tries to use local time.
By calling early in your program either Logger::use_utc()
or directly this method,
you can override this to always use UTC.
§Panics
Panics if called too late, i.e., if DeferredNow::now
was already called before on
any instance of DeferredNow
.