Crate vlog [−] [src]
vlog
Macros to do stdout / stderr logs based on verbosity level.
Useful for CLI applications. The default verbosity level is 0, and the
supported max verbosity level is 3, which is equivalent to -vvv
flags seen
in most Linux CLI applications.
Example
#[macro_use] extern crate vlog; use vlog::{get_verbosity_level, set_verbosity_level}; fn main() { // default verbosity level is 0 assert_eq!(0, get_verbosity_level()); v0!("v0 stdout prints"); v1!("v1 stdout won't print"); v2!("v2 stdout won't print"); v3!("v3 stdout won't print"); // set custom verbosity level set_verbosity_level(1); assert_eq!(1, get_verbosity_level()); v0!("{} stdout prints", "v0"); v1!("{} stdout prints", "v1"); v2!("{} stdout won't print", "v2"); v3!("{} stdout won't print", "v3"); // set custom max verbosity level set_verbosity_level(3); assert_eq!(3, get_verbosity_level()); v0!("{} stdout prints", "v0"); v1!("{} stdout prints", "v1"); v2!("{} stdout prints", "v2"); v3!("{} stdout prints", "v3"); // stderr macros also available ve0!("{} stderr prints", "ve0"); ve1!("{} stderr prints", "ve1"); ve2!("{} stderr prints", "ve2"); ve3!("{} stderr prints", "ve3"); }
Macros
v0 |
Always prints to |
v1 |
Prints to |
v2 |
Prints to |
v3 |
Prints to |
ve0 |
Always prints to |
ve1 |
Prints to |
ve2 |
Prints to |
ve3 |
Prints to |
verbose_elog |
Common macro for verbose |
verbose_log |
Common macro for verbose |
Functions
get_verbosity_level |
Gets the application verbosity level atomically. This method is thread-safe. |
set_verbosity_level |
Sets the application verbosity level atomically. This method is thread-safe. |