https://github.com/guangie88/vlog-rs
Macros to do stdout / stderr logs based on verbosity level
https://github.com/guangie88/vlog-rs
cli log rust verbosity-level
Last synced: 1 day ago
JSON representation
Macros to do stdout / stderr logs based on verbosity level
- Host: GitHub
- URL: https://github.com/guangie88/vlog-rs
- Owner: guangie88
- License: mit
- Created: 2018-04-14T12:37:47.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-09T00:19:03.000Z (about 8 years ago)
- Last Synced: 2025-12-29T22:03:59.231Z (6 months ago)
- Topics: cli, log, rust, verbosity-level
- Language: Rust
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vlog-rs
[](https://travis-ci.org/guangie88/vlog-rs)
[](https://ci.appveyor.com/project/guangie88/vlog-rs/branch/master)
[](https://codecov.io/gh/guangie88/vlog-rs)
[](https://crates.io/crates/vlog)
[](https://docs.rs/vlog)
[](https://opensource.org/licenses/MIT)
Macros to do stdout / stderr logs based on verbosity level, which take in the
same arguments as
[`println!`](https://doc.rust-lang.org/1.0.0/std/macro.println!.html) 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
```rust
#[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");
}
```