From 18cf39d06384ba76d121639ea925c76b5ec5ccd7 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 12 Feb 2025 11:49:10 +0100 Subject: [PATCH] Rust: add verbosity and flamegraph as extractor options --- rust/codeql-extractor.yml | 24 ++++++++++++++++++++++++ rust/extractor/src/config.rs | 12 +++++++++--- rust/extractor/src/main.rs | 4 ++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/rust/codeql-extractor.yml b/rust/codeql-extractor.yml index 2f726a10ada..27f423134a6 100644 --- a/rust/codeql-extractor.yml +++ b/rust/codeql-extractor.yml @@ -54,3 +54,27 @@ options: Comma-separated list of cfg settings to enable, or disable if prefixed with `-`. Can be repeated. type: array + logging: + title: Options pertaining to logging. + type: object + properties: + verbosity: + title: Extractor logging verbosity level. + description: > + Controls the level of verbosity of the extractor. + The supported levels are (in order of increasing verbosity): + - off + - errors + - warnings + - info or progress + - debug or progress+ + - trace or progress++ + - progress+++ + type: string + pattern: "^(off|errors|warnings|(info|progress)|(debug|progress\\+)|(trace|progress\\+\\+)|progress\\+\\+\\+)$" + flamegraph: + title: "[Experimental] File path for write flame graph log" + description: > + Collect flame graph data using the `tracing-flame` crate. To render a flame graph + or chart, run the `inferno-flamegraph` command. See also: https://crates.io/crates/tracing-flame + type: string diff --git a/rust/extractor/src/config.rs b/rust/extractor/src/config.rs index f852ee4c4b6..82568b64553 100644 --- a/rust/extractor/src/config.rs +++ b/rust/extractor/src/config.rs @@ -50,8 +50,8 @@ pub struct Config { pub cargo_target: Option, pub cargo_features: Vec, pub cargo_cfg_overrides: Vec, - pub flame_log: Option, - pub verbosity: Option, + pub logging_flamegraph: Option, + pub logging_verbosity: Option, pub compression: Compression, pub inputs: Vec, pub qltest: bool, @@ -65,7 +65,13 @@ impl Config { .context("expanding parameter files")?; let cli_args = CliConfig::parse_from(args); let mut figment = Figment::new() - .merge(Env::prefixed("CODEQL_")) + .merge(Env::raw().filter_map(|f| { + if f.eq("CODEQL_VERBOSITY") { + Some("LOGGING_VERBOSITY".into()) + } else { + None + } + })) .merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_")) .merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_OPTION_")) .merge(Serialized::defaults(cli_args)); diff --git a/rust/extractor/src/main.rs b/rust/extractor/src/main.rs index 48eecaad462..04aaf23c652 100644 --- a/rust/extractor/src/main.rs +++ b/rust/extractor/src/main.rs @@ -186,7 +186,7 @@ fn main() -> anyhow::Result<()> { qltest::prepare(&mut cfg)?; } let start = Instant::now(); - let (flame_layer, _flush_guard) = if let Some(path) = &cfg.flame_log { + let (flame_layer, _flush_guard) = if let Some(path) = &cfg.logging_flamegraph { tracing_flame::FlameLayer::with_file(path) .ok() .map(|(a, b)| (Some(a), Some(b))) @@ -198,7 +198,7 @@ fn main() -> anyhow::Result<()> { tracing_subscriber::registry() .with(codeql_extractor::extractor::default_subscriber_with_level( "single_arch", - &cfg.verbosity, + &cfg.logging_verbosity, )) .with(flame_layer) .init();