From 00def9e19aa45d04faca48675ab5016d9d7dd7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sat, 15 Jan 2022 15:14:25 +1300 Subject: [PATCH] Use pretty logging at high -vvvv --- cli/src/args.rs | 2 +- cli/src/main.rs | 20 +++++++++++++++----- cli/tests/snapshots/help__help_unix.snap | 2 +- cli/tests/snapshots/help__help_windows.snap | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cli/src/args.rs b/cli/src/args.rs index 2a56c90..54cc4e7 100644 --- a/cli/src/args.rs +++ b/cli/src/args.rs @@ -85,7 +85,7 @@ pub fn get_args(tagged_filterer: bool) -> Result> { .long("debounce")) .arg(Arg::with_name("verbose") .help_heading(Some(OPTSET_DEBUGGING)) - .help("Print debugging messages (-v, -vv, -vvv; use -vvv for bug reports)") + .help("Print debugging messages (-v, -vv, -vvv, -vvvv; use -vvv for bug reports)") .multiple(true) .short("v") .long("verbose")) diff --git a/cli/src/main.rs b/cli/src/main.rs index 9927844..c02e6b2 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -26,15 +26,25 @@ async fn main() -> Result<()> { let args = args::get_args(tagged_filterer)?; - tracing_subscriber::fmt() - .with_env_filter(match args.occurrences_of("verbose") { + { + let verbosity = args.occurrences_of("verbose"); + let mut builder = tracing_subscriber::fmt().with_env_filter(match verbosity { 0 => "watchexec-cli=warn", 1 => "watchexec=debug,watchexec-cli=debug", 2 => "watchexec=trace,watchexec-cli=trace", _ => "trace", - }) - .try_init() - .ok(); + }); + + if verbosity > 2 { + builder = builder.with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL); + } + + if verbosity > 3 { + builder.pretty().try_init().ok(); + } else { + builder.try_init().ok(); + } + } let init = config::init(&args)?; let mut runtime = config::runtime(&args)?; diff --git a/cli/tests/snapshots/help__help_unix.snap b/cli/tests/snapshots/help__help_unix.snap index 2041c2b..3dcbff6 100644 --- a/cli/tests/snapshots/help__help_unix.snap +++ b/cli/tests/snapshots/help__help_unix.snap @@ -25,7 +25,7 @@ FLAGS: --print-events Print events that trigger actions -r, --restart Restart the process if it's still running. Shorthand for --on-busy-update=restart -V, --version Prints version information - -v, --verbose Print debugging messages (-v, -vv, -vvv; use -vvv for bug reports) + -v, --verbose Print debugging messages (-v, -vv, -vvv, -vvvv; use -vvv for bug reports) OPTIONS: -d, --debounce Set the timeout between detected change and command execution, defaults to diff --git a/cli/tests/snapshots/help__help_windows.snap b/cli/tests/snapshots/help__help_windows.snap index 4f16eb2..ce62617 100644 --- a/cli/tests/snapshots/help__help_windows.snap +++ b/cli/tests/snapshots/help__help_windows.snap @@ -25,7 +25,7 @@ FLAGS: --print-events Print events that trigger actions -r, --restart Restart the process if it's still running. Shorthand for --on-busy-update=restart -V, --version Prints version information - -v, --verbose Print debugging messages (-v, -vv, -vvv; use -vvv for bug reports) + -v, --verbose Print debugging messages (-v, -vv, -vvv, -vvvv; use -vvv for bug reports) OPTIONS: -d, --debounce Set the timeout between detected change and command execution, defaults to