Function stdcli::init_log
[−]
[src]
pub fn init_log(verbosity: u64, stderr: bool, logfile: Option<&Path>)
One liner to init loglevel using a number for the verbosity. The verbosities are:
- 0
: exit immediately (no logging)
- 1
: Critical + Error
- 2
: Info
- 3
: Debug
- 4
: Trace
This function panics if there is an error. Intended for use in initial script development.
Later development should use fern
or another logging backend directly.
Example
In your main function:
#[macro_use] extern crate stdcli; #[macro_use] extern crate log; use stdcli::prelude::*; fn main() { // verbosity=2, stderr=true, logfile=None init_log(2, true, None); info!("log at the info level"); debug!("this will not be logged unless level is increased to 3"); }