Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the -v flag #21

Open
vorner opened this issue Sep 4, 2018 · 2 comments
Open

Support the -v flag #21

vorner opened this issue Sep 4, 2018 · 2 comments

Comments

@vorner
Copy link
Owner

vorner commented Sep 4, 2018

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

@myrrlyn
Copy link
Contributor

myrrlyn commented Sep 8, 2018

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();

@vorner
Copy link
Owner Author

vorner commented Sep 9, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants