From 947865c05478fce0675fce93fd2811f93b703287 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Sat, 9 Sep 2023 12:03:19 -0600 Subject: feat(cli): allow --log-level=trace for additional deep debugging (#20426) This allows us to opt in to extremely detailed tracing from dependency libraries, like so: ``` cargo run --features tracing/log,tracing/max_level_trace -- test --log-level=trace -A --unstable ./cli/tests/unit/serve_test.ts ``` It will not impact normal operation as it requires the `tracing/max_level_trace` and `tracing/log` to be active. Note that tracing is already a dependency -- this just makes it a direct dep of cli so we can access its features more easily. --- Cargo.lock | 1 + Cargo.toml | 1 + cli/Cargo.toml | 1 + cli/args/flags.rs | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d538c3dd0..7403b26dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -922,6 +922,7 @@ dependencies = [ "tokio", "tokio-util", "tower-lsp", + "tracing", "trust-dns-client", "trust-dns-server", "twox-hash", diff --git a/Cargo.toml b/Cargo.toml index 167a51960..1bfab9fa1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -139,6 +139,7 @@ tar = "=0.4.40" tempfile = "3.4.0" termcolor = "1.1.3" thiserror = "1.0.40" +tracing = "0" tokio = { version = "1.28.1", features = ["full"] } tokio-metrics = { version = "0.3.0", features = ["rt"] } tokio-rustls = "0.24.0" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index fceaeccac..e713a1a64 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -116,6 +116,7 @@ thiserror.workspace = true tokio.workspace = true tokio-util.workspace = true tower-lsp.workspace = true +tracing.workspace = true twox-hash = "=1.6.3" typed-arena = "=2.0.1" uuid = { workspace = true, features = ["serde"] } diff --git a/cli/args/flags.rs b/cli/args/flags.rs index c09d4e7e9..b69f1ce8f 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -796,6 +796,7 @@ pub fn flags_from_vec(args: Vec) -> clap::error::Result { flags.log_level = Some(Level::Error); } else if let Some(log_level) = matches.get_one::("log-level") { flags.log_level = match log_level.as_str() { + "trace" => Some(Level::Trace), "debug" => Some(Level::Debug), "info" => Some(Level::Info), _ => unreachable!(), @@ -891,7 +892,7 @@ fn clap_root() -> Command { .long("log-level") .help("Set log level") .hide(true) - .value_parser(["debug", "info"]) + .value_parser(["trace", "debug", "info"]) .global(true), ) .arg( -- cgit v1.2.3