pub struct LoggingTimer<'name> { /* private fields */ }
Expand description

When this struct is dropped, it logs a message stating its name and how long the execution time was. Can be used to time functions or other critical areas.

Implementations§

source§

impl<'name> LoggingTimer<'name>

source

pub fn new( file: &'static str, module_path: &'static str, line: u32, name: &'name str, extra_info: Option<String>, level: Level ) -> Option<Self>

Constructs a new LoggingTimer that prints only a ‘TimerFinished’ message. This method is not usually called directly, use the timer! macro instead.

source

pub fn with_start_message( file: &'static str, module_path: &'static str, line: u32, name: &'name str, extra_info: Option<String>, level: Level ) -> Option<Self>

Constructs a new LoggingTimer that prints a ‘TimerStarting’ and a ‘TimerFinished’ message. This method is not usually called directly, use the stimer! macro instead.

source

pub fn elapsed(&self) -> Duration

Returns how long the timer has been running for.

source

pub fn level(self, level: Level) -> Self

👎Deprecated since 0.3.0: Please use the first parameter to the timer or stimer macro instead

Sets the logging level. Note that this consumes self, so that it can be called in a one-liner like this:

let tmr = timer!("foo").level(Level::Trace);
source

pub fn executing(&self, args: Option<Arguments<'_>>)

Outputs a log message with a target of ‘TimerExecuting’ showing the current elapsed time, but does not stop the timer. This method can be called multiple times. The message can include further information via a format_args! approach. This method is usually not called directly, it is easier to use the executing! macro.

source

pub fn finish(&self, args: Option<Arguments<'_>>)

Outputs a log message with a target of ‘TimerFinished’ and suppresses the normal message that is output when the timer is dropped. The message can include further format_args! information. This method is normally called using the finish! macro. Calling finish() again will have no effect.

Trait Implementations§

source§

impl<'a> Drop for LoggingTimer<'a>

source§

fn drop(&mut self)

Drops the timer, outputting a log message with a target of TimerFinished if the finish method has not yet been called.

Auto Trait Implementations§

§

impl<'name> RefUnwindSafe for LoggingTimer<'name>

§

impl<'name> Send for LoggingTimer<'name>

§

impl<'name> Sync for LoggingTimer<'name>

§

impl<'name> Unpin for LoggingTimer<'name>

§

impl<'name> UnwindSafe for LoggingTimer<'name>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.