Skip to content

Commit 2df8d57

Browse files
committed
Rust: add verbosity and flamegraph as extractor options
1 parent 64f0908 commit 2df8d57

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

rust/codeql-extractor.yml

+25
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,28 @@ options:
5454
Comma-separated list of cfg settings to enable, or disable if prefixed with `-`.
5555
Can be repeated.
5656
type: array
57+
logging:
58+
title: Options pertaining to logging.
59+
type: object
60+
properties:
61+
verbosity:
62+
title: Extractor logging verbosity level.
63+
description: >
64+
Controls the level of verbosity of the extractor.
65+
The supported levels are (in order of increasing verbosity):
66+
- off
67+
- errors
68+
- warnings
69+
- info or progress
70+
- debug or progress+
71+
- trace or progress++
72+
- progress+++
73+
type: string
74+
pattern: "^(off|errors|warnings|(info|progress)|(debug|progress\\+)|(trace|progress\\+\\+)|progress\\+\\+\\+)$"
75+
flamegraph:
76+
title: [Experimental] File path for write flame graph log
77+
description: >
78+
Collect flame graph data using the `tracing-flame` crate. To render a flame graph
79+
or chart, run the `inferno-flamegraph` command. See also: https://crates.io/crates/tracing-flame
80+
type: string
81+

rust/extractor/src/config.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pub struct Config {
5050
pub cargo_target: Option<String>,
5151
pub cargo_features: Vec<String>,
5252
pub cargo_cfg_overrides: Vec<String>,
53-
pub flame_log: Option<PathBuf>,
54-
pub verbosity: Option<String>,
53+
pub logging_flamegraph: Option<PathBuf>,
54+
pub logging_verbosity: Option<String>,
5555
pub compression: Compression,
5656
pub inputs: Vec<PathBuf>,
5757
pub qltest: bool,
@@ -65,7 +65,13 @@ impl Config {
6565
.context("expanding parameter files")?;
6666
let cli_args = CliConfig::parse_from(args);
6767
let mut figment = Figment::new()
68-
.merge(Env::prefixed("CODEQL_"))
68+
.merge(Env::raw().filter_map(|f| {
69+
if f.eq("CODEQL_VERBOSITY") {
70+
Some("LOGGING_VERBOSITY".into())
71+
} else {
72+
None
73+
}
74+
}))
6975
.merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_"))
7076
.merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_OPTION_"))
7177
.merge(Serialized::defaults(cli_args));

rust/extractor/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn main() -> anyhow::Result<()> {
186186
qltest::prepare(&mut cfg)?;
187187
}
188188
let start = Instant::now();
189-
let (flame_layer, _flush_guard) = if let Some(path) = &cfg.flame_log {
189+
let (flame_layer, _flush_guard) = if let Some(path) = &cfg.logging_flamegraph {
190190
tracing_flame::FlameLayer::with_file(path)
191191
.ok()
192192
.map(|(a, b)| (Some(a), Some(b)))
@@ -198,7 +198,7 @@ fn main() -> anyhow::Result<()> {
198198
tracing_subscriber::registry()
199199
.with(codeql_extractor::extractor::default_subscriber_with_level(
200200
"single_arch",
201-
&cfg.verbosity,
201+
&cfg.logging_verbosity,
202202
))
203203
.with(flame_layer)
204204
.init();

0 commit comments

Comments
 (0)