spirit icon indicating copy to clipboard operation
spirit copied to clipboard

Support the -v flag

Open vorner opened this issue 7 years ago • 2 comments

Users might reasonably expect the -v to mean verbose output. Think about how it is possible to combine together with specifying log levels explicitly.

vorner avatar Sep 04 '18 09:09 vorner

Clap (and thus presumably StructOpt) supports counting how many times a flag is passed. Counting occurrences of -v (including compressed forms like -vv) could monotonically increase the verbosity. Example code:

let filters: Vec<LevelFilter> = [
  LevelFilter::Error,
  LevelFilter::Warn,
  LevelFilter::Info,
  LevelFilter::Debug,
  LevelFilter::Trace,
][..= std::cmp::min(args.occurrences_of("verbosity"), 4]
  .iter().cloned().collect();

myrrlyn avatar Sep 08 '18 00:09 myrrlyn

Yes, I know, there's even a crate for that (clap-verbosity-flag, I think).

However, if I want to set the logging to debug, having to count how many -vs I need is just terrible UX, especially with daemons, which you don't want to run again and again, tweaking the debugging. Furthermore, the command line allows setting log levels for specific crates (which is often quite useful in larger projects ‒ which daemons often happen to be). Repetitive -v doesn't sound consistent with it.

So I'm more thinking about keeping the -l flag for logging level and -v would just set it to Debug, as a shortcut.

vorner avatar Sep 09 '18 16:09 vorner