[][src]Macro tao_log::logv

macro_rules! logv {
    (target: $target:expr, $lvl:expr, $($arg:tt)+) => { ... };
    ($lvl:expr, $($arg:tt)+) => { ... };
}

Log an expression and its value at any specified level.

Logs with the optional or default (module path of use) target, specified Level, optional prefix, and optional or default ("{:?}") value format string, and a single expression. The expression argument is evaluated exactly once, regardless of if the logging level is enabled, and its value is returned from the macro. This is normally only used through the -v macros like debugv! or tracev!.

Note that the value is moved and then returned. If the type does not implement Copy, ownership may be retained by borrowing by reference e.g. debugv!(&expr).

Examples

use tao_log::*;

#[derive(Debug)]
struct Point { x: f32, y: f32 }

fn circle(center: &Point, radius: f32) { /*...*/ }

let center = Point { x: 3.234, y: -1.223 };

circle(logv!(log::Level::Trace, &center), 7.3);
//     ^-- trace level message: "&center → Point { x: 3.234, y: -1.223 }"
circle(tracev!(&center), 8.0);
//     ^-- trace level message: "&center → Point { x: 3.234, y: -1.223 }"