Skip to content

Commit 5621eec

Browse files
committed
Rust: config: replace verbose with verbosity
1 parent 3218fae commit 5621eec

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

rust/extractor/src/config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use figment::{
1010
Figment,
1111
};
1212
use itertools::Itertools;
13-
use num_traits::Zero;
1413
use ra_ap_cfg::{CfgAtom, CfgDiff};
1514
use ra_ap_ide_db::FxHashMap;
1615
use ra_ap_intern::Symbol;
@@ -52,7 +51,7 @@ pub struct Config {
5251
pub cargo_features: Vec<String>,
5352
pub cargo_cfg_overrides: Vec<String>,
5453
pub flame_log: Option<PathBuf>,
55-
pub verbose: u8,
54+
pub verbosity: Option<String>,
5655
pub compression: Compression,
5756
pub inputs: Vec<PathBuf>,
5857
pub qltest: bool,
@@ -66,7 +65,7 @@ impl Config {
6665
.context("expanding parameter files")?;
6766
let cli_args = CliConfig::parse_from(args);
6867
let mut figment = Figment::new()
69-
.merge(Env::raw().only(["CODEQL_VERBOSE"].as_slice()))
68+
.merge(Env::prefixed("CODEQL_"))
7069
.merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_"))
7170
.merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_OPTION_"))
7271
.merge(Serialized::defaults(cli_args));

rust/extractor/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ fn main() -> anyhow::Result<()> {
194194
tracing_subscriber::registry()
195195
.with(codeql_extractor::extractor::default_subscriber_with_level(
196196
"single_arch",
197+
&cfg.verbosity,
197198
))
198199
.with(flame_layer.map(|x| x.0))
199200
.init();

shared/tree-sitter-extractor/src/extractor/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ pub mod simple;
2222
/// `RUST_LOG` and `CODEQL_VERBOSITY` (prioritized in that order),
2323
/// falling back to `warn` if neither is set.
2424
pub fn set_tracing_level(language: &str) {
25+
let verbosity = env::var("CODEQL_VERBOSITY").ok();
2526
tracing_subscriber::registry()
26-
.with(default_subscriber_with_level(language))
27+
.with(default_subscriber_with_level(language, &verbosity))
2728
.init();
2829
}
2930

3031
/// Create a `Subscriber` configured with the tracing level based on the environment variables
31-
/// `RUST_LOG` and `CODEQL_VERBOSITY` (prioritized in that order), falling back to `warn` if neither is set.
32+
/// `RUST_LOG` and `verbosity` (prioritized in that order), falling back to `warn` if neither is set.
3233
pub fn default_subscriber_with_level(
3334
language: &str,
35+
verbosity: &Option<String>,
3436
) -> Filtered<
3537
tracing_subscriber::fmt::Layer<
3638
tracing_subscriber::Registry,
@@ -47,7 +49,8 @@ pub fn default_subscriber_with_level(
4749
.with_filter(
4850
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(
4951
|_| -> tracing_subscriber::EnvFilter {
50-
let verbosity = env::var("CODEQL_VERBOSITY")
52+
let verbosity = verbosity
53+
.as_ref()
5154
.map(|v| match v.to_lowercase().as_str() {
5255
"off" | "errors" => "error",
5356
"warnings" => "warn",
@@ -56,7 +59,7 @@ pub fn default_subscriber_with_level(
5659
"trace" | "progress++" | "progress+++" => "trace",
5760
_ => "warn",
5861
})
59-
.unwrap_or_else(|_| "warn");
62+
.unwrap_or_else(|| "warn");
6063
tracing_subscriber::EnvFilter::new(format!(
6164
"{language}_extractor={verbosity},codeql_extractor={verbosity}"
6265
))

0 commit comments

Comments
 (0)