// Copyright 2018 Doug Goldstein // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use log::*; use structopt::StructOpt; /// A basic example #[derive(StructOpt, Debug)] #[structopt()] struct Opt { /// Silence all output #[structopt(short = "q", long = "quiet")] quiet: bool, /// Verbose mode (-v, -vv, -vvv, etc.) #[structopt(short = "v", long = "verbose", parse(from_occurrences))] verbose: usize, /// Timestamp (sec, ms, us, ns, none) #[structopt(short = "t", long = "timestamp")] ts: Option, } fn main() { let opt = Opt::from_args(); stderrlog::new() .module(module_path!()) .quiet(opt.quiet) .verbosity(opt.verbose) .timestamp(opt.ts.unwrap_or(stderrlog::Timestamp::Off)) .init() .unwrap(); trace!("{} - trace message", module_path!()); debug!("{} - debug message", module_path!()); info!("{} - info message", module_path!()); warn!("{} - warn message", module_path!()); error!("{} - error message", module_path!()); }