Struct custom_utils::logger::DeferredNow
source · pub struct DeferredNow(_);
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 new() -> DeferredNow
pub fn new() -> DeferredNow
Constructs a new instance, but does not generate the timestamp.
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 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
.