#cli

vlog

Macros to do stdout / stderr logs based on verbosity level

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

Download history 10122/week @ 2024-07-27 16311/week @ 2024-08-03 219/week @ 2024-08-10 116/week @ 2024-08-17 235/week @ 2024-08-24 121/week @ 2024-08-31 289/week @ 2024-09-07 183/week @ 2024-09-14 274/week @ 2024-09-21 199/week @ 2024-09-28 207/week @ 2024-10-05 138/week @ 2024-10-12 341/week @ 2024-10-19 254/week @ 2024-10-26 52/week @ 2024-11-02 66/week @ 2024-11-09

727 downloads per month
Used in 4 crates

MIT license

10KB
94 lines

vlog-rs

Build Status Build status codecov Crates.io Docs.rs License: MIT

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");
}

No runtime deps