5 releases
Uses old Rust 2015
0.1.4 | May 9, 2018 |
---|---|
0.1.3 | May 8, 2018 |
0.1.2 | Apr 24, 2018 |
0.1.1 | Apr 14, 2018 |
0.1.0 | Apr 14, 2018 |
#616 in Command-line interface
727 downloads per month
Used in 4 crates
10KB
94 lines
vlog-rs
Macros to do stdout / stderr logs based on verbosity level, which take in the
same arguments as
println!
macro.
Useful for CLI applications. The default verbosity level is 0, and the supported
max verbosity level is 3, which is equivalent to -vvv
flags as 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");
}