pretty-flexible-env-logger

Crates.io Docs CC0-1.0 GitHub CI

A simple logger built on top of prettyenvlogger. An upstream's design decision was not to allow run-time configuration, but I have found that for CLI tools it actually makes sense to control logging in runtime based on command-line params, rather than requiring users to set RUST_LOG directly.

To keep things simple, init_with tries to look up passed string as an environment variable, and if that fails it considers the value to be inlined configuration, same as you would set RUST_LOG with.

```rust let args: Vec = env::args().collect(); let default = "RUSTLOG".tostring(); let level = args.get(1).unwrapor(&default); if let Err(e) = prettyflexibleenvlogger::tryinitwith(level) { eprintln!("Some custom msg {}", e); panic!("error!") // or whatever }

info!("info"); warn!("warn"); error!("error"); debug!("debug"); ```

License

Related Work

This crate is a little contribution built on the shoulders of giants: - prettyenvlogger - env_logger