mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: config: replace verbose with verbosity
This commit is contained in:
@@ -10,7 +10,6 @@ use figment::{
|
||||
Figment,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use num_traits::Zero;
|
||||
use ra_ap_cfg::{CfgAtom, CfgDiff};
|
||||
use ra_ap_ide_db::FxHashMap;
|
||||
use ra_ap_intern::Symbol;
|
||||
@@ -52,7 +51,7 @@ pub struct Config {
|
||||
pub cargo_features: Vec<String>,
|
||||
pub cargo_cfg_overrides: Vec<String>,
|
||||
pub flame_log: Option<PathBuf>,
|
||||
pub verbose: u8,
|
||||
pub verbosity: Option<String>,
|
||||
pub compression: Compression,
|
||||
pub inputs: Vec<PathBuf>,
|
||||
pub qltest: bool,
|
||||
@@ -66,7 +65,7 @@ impl Config {
|
||||
.context("expanding parameter files")?;
|
||||
let cli_args = CliConfig::parse_from(args);
|
||||
let mut figment = Figment::new()
|
||||
.merge(Env::raw().only(["CODEQL_VERBOSE"].as_slice()))
|
||||
.merge(Env::prefixed("CODEQL_"))
|
||||
.merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_"))
|
||||
.merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_OPTION_"))
|
||||
.merge(Serialized::defaults(cli_args));
|
||||
|
||||
@@ -194,6 +194,7 @@ fn main() -> anyhow::Result<()> {
|
||||
tracing_subscriber::registry()
|
||||
.with(codeql_extractor::extractor::default_subscriber_with_level(
|
||||
"single_arch",
|
||||
&cfg.verbosity,
|
||||
))
|
||||
.with(flame_layer.map(|x| x.0))
|
||||
.init();
|
||||
|
||||
@@ -22,15 +22,17 @@ pub mod simple;
|
||||
/// `RUST_LOG` and `CODEQL_VERBOSITY` (prioritized in that order),
|
||||
/// falling back to `warn` if neither is set.
|
||||
pub fn set_tracing_level(language: &str) {
|
||||
let verbosity = env::var("CODEQL_VERBOSITY").ok();
|
||||
tracing_subscriber::registry()
|
||||
.with(default_subscriber_with_level(language))
|
||||
.with(default_subscriber_with_level(language, &verbosity))
|
||||
.init();
|
||||
}
|
||||
|
||||
/// Create a `Subscriber` configured with the tracing level based on the environment variables
|
||||
/// `RUST_LOG` and `CODEQL_VERBOSITY` (prioritized in that order), falling back to `warn` if neither is set.
|
||||
/// `RUST_LOG` and `verbosity` (prioritized in that order), falling back to `warn` if neither is set.
|
||||
pub fn default_subscriber_with_level(
|
||||
language: &str,
|
||||
verbosity: &Option<String>,
|
||||
) -> Filtered<
|
||||
tracing_subscriber::fmt::Layer<
|
||||
tracing_subscriber::Registry,
|
||||
@@ -47,7 +49,8 @@ pub fn default_subscriber_with_level(
|
||||
.with_filter(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(
|
||||
|_| -> tracing_subscriber::EnvFilter {
|
||||
let verbosity = env::var("CODEQL_VERBOSITY")
|
||||
let verbosity = verbosity
|
||||
.as_ref()
|
||||
.map(|v| match v.to_lowercase().as_str() {
|
||||
"off" | "errors" => "error",
|
||||
"warnings" => "warn",
|
||||
@@ -56,7 +59,7 @@ pub fn default_subscriber_with_level(
|
||||
"trace" | "progress++" | "progress+++" => "trace",
|
||||
_ => "warn",
|
||||
})
|
||||
.unwrap_or_else(|_| "warn");
|
||||
.unwrap_or_else(|| "warn");
|
||||
tracing_subscriber::EnvFilter::new(format!(
|
||||
"{language}_extractor={verbosity},codeql_extractor={verbosity}"
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user