Struct clilog::LoggingTimer
source · [−]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
sourceimpl<'name> LoggingTimer<'name>
impl<'name> LoggingTimer<'name>
sourcepub fn new(
file: &'static str,
module_path: &'static str,
line: u32,
name: &'name str,
extra_info: Option<String>,
level: Level
) -> Option<Self>
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.
sourcepub fn with_start_message(
file: &'static str,
module_path: &'static str,
line: u32,
name: &'name str,
extra_info: Option<String>,
level: Level
) -> Option<Self>
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.
sourcepub fn level(self, level: Level) -> Self
👎 Deprecated since 0.3: Please use the first parameter to the timer
or stimer
macro instead
pub fn level(self, level: Level) -> Self
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);
sourcepub fn executing(&self, args: Option<Arguments<'_>>)
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.
sourcepub fn finish(&self, args: Option<Arguments<'_>>)
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
sourceimpl<'a> Drop for LoggingTimer<'a>
impl<'a> Drop for LoggingTimer<'a>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more