Skip to content

Commit

Permalink
feat(cli/setup-mode)!: set log level to DEBUG on --verbose if `RU…
Browse files Browse the repository at this point in the history
…STUP_LOG` is unset
  • Loading branch information
rami3l committed Aug 11, 2024
1 parent d4e4b7f commit fc0e7f1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rustup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Usage: rustup-init[EXE] [OPTIONS]
Options:
-v, --verbose
Enable verbose output
Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is unset
-q, --quiet
Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is unset
-y
Expand Down
21 changes: 14 additions & 7 deletions src/cli/setup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ use crate::{
before_help = format!("rustup-init {}", common::version()),
)]
struct RustupInit {
/// Enable verbose output
#[arg(short, long)]
/// Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is unset
#[arg(short, long, overrides_with = "quiet")]
verbose: bool,

/// Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is unset
#[arg(short, long)]
#[arg(short, long, overrides_with = "verbose")]
quiet: bool,

/// Disable confirmation prompt
Expand Down Expand Up @@ -115,10 +115,17 @@ pub async fn main(
warn!("{}", common::WARN_COMPLETE_PROFILE);
}

if quiet && process.var("RUSTUP_LOG").is_err() {
console_filter
.modify(|it| *it = EnvFilter::new("rustup=WARN"))
.expect("error reloading `EnvFilter` for console_logger");
if process.var("RUSTUP_LOG").is_err() {
if quiet {
console_filter
.modify(|it| *it = EnvFilter::new("rustup=WARN"))
.expect("error reloading `EnvFilter` for console_logger");
}
if verbose {
console_filter
.modify(|it| *it = EnvFilter::new("rustup=DEBUG"))
.expect("error reloading `EnvFilter` for console_logger");
}
}

let opts = InstallOpts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Usage: rustup-init[EXE] [OPTIONS]
Options:
-v, --verbose
Enable verbose output
Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is unset
-q, --quiet
Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is unset
-y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Usage: rustup-init[EXE] [OPTIONS]
Options:
-v, --verbose
Enable verbose output
Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is unset
-q, --quiet
Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is unset
-y
Expand Down

0 comments on commit fc0e7f1

Please sign in to comment.