Expand description
The crate provides macros, which measure the time in ms until end of scope
This is done by creating an object, which measures the time. The time is printed when the object is dropped.
The logging behaviour is the same as other log macros like info!(..)
§Examples
use measure_time::{info_time, debug_time, trace_time, error_time, print_time};
info_time!("measure function");
{
debug_time!("{:?}", "measuring block");
let mut sum = 0;
for el in 0..50000 {
sum+=el;
}
println!("{:?}", sum);
}
trace_time!("{:?}", "trace");
print_time!("print");
error_time!(target: "measure_time", "custom target");
// --> prints "yep took ...", "measuring function took 0.0135ms"
Macros§
- debug
- Logs a message at the debug level.
- debug_
time - logs the time with the debug! macro
- error
- Logs a message at the error level.
- error_
time - logs the time with the error! macro
- info
- Logs a message at the info level.
- info_
time - logs the time with the info! macro
- log
- The standard logging macro.
- log_
enabled - Determines if a message logged at the specified level in that module will be logged.
- log_
time - print_
time - logs the time with the print! macro
- trace
- Logs a message at the trace level.
- trace_
time - logs the time with the trace! macro
- warn
- Logs a message at the warn level.
- warn_
time - logs the time with the warn! macro
Structs§
- Measure
Time - Metadata
- Metadata about a log message.
- Metadata
Builder - Builder for
Metadata
. - Parse
Level Error - The type returned by
from_str
when the string doesn’t match any of the log levels. - Record
- The “payload” of a log message.
- Record
Builder - Builder for
Record
. - SetLogger
Error - The type returned by
set_logger
ifset_logger
has already been called.
Enums§
- Level
- An enum representing the available verbosity levels of the logger.
- Level
Filter - An enum representing the available verbosity level filters of the logger.
Constants§
- STATIC_
MAX_ LEVEL - The statically resolved maximum log level.
Traits§
- Log
- A trait encapsulating the operations required of a logger.
Functions§
- logger
- Returns a reference to the logger.
- max_
level - Returns the current maximum log level.
- set_
logger - Sets the global logger to a
&'static Log
. - set_
logger_ ⚠racy - A thread-unsafe version of
set_logger
. - set_
max_ level - Sets the global maximum log level.
- set_
max_ ⚠level_ racy - A thread-unsafe version of
set_max_level
.