Skip to content

Commit ce06464

Browse files
committed
fixup! feat(cli)!: set log level to DEBUG on --verbose if RUSTUP_LOG is unset
1 parent 48412d4 commit ce06464

File tree

5 files changed

+24
-35
lines changed

5 files changed

+24
-35
lines changed

src/bin/rustup-init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async fn run_rustup_inner(
9393
utils::current_exe()?;
9494

9595
match process.name().as_deref() {
96-
Some("rustup") => rustup_mode::main(current_dir, process, Some(console_filter)).await,
96+
Some("rustup") => rustup_mode::main(current_dir, process, console_filter).await,
9797
Some(n) if n.starts_with("rustup-setup") || n.starts_with("rustup-init") => {
9898
// NB: The above check is only for the prefix of the file
9999
// name. Browsers rename duplicates to

src/cli/rustup_mode.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ enum SetSubcmd {
536536
pub async fn main(
537537
current_dir: PathBuf,
538538
process: &Process,
539-
console_filter: Option<Handle<EnvFilter, Registry>>,
539+
console_filter: Handle<EnvFilter, Registry>,
540540
) -> Result<utils::ExitCode> {
541541
self_update::cleanup_self_updater(process)?;
542542

@@ -576,17 +576,15 @@ pub async fn main(
576576
};
577577

578578
if process.var("RUSTUP_LOG").is_err() {
579-
if let Some(console_filter) = &console_filter {
580-
if matches.quiet {
581-
console_filter
582-
.modify(|it| *it = EnvFilter::new("rustup=WARN"))
583-
.expect("error reloading `EnvFilter` for console_logger")
584-
}
585-
if matches.verbose {
586-
console_filter
587-
.modify(|it| *it = EnvFilter::new("rustup=DEBUG"))
588-
.expect("error reloading `EnvFilter` for console_logger")
589-
}
579+
if matches.quiet {
580+
console_filter
581+
.modify(|it| *it = EnvFilter::new("rustup=WARN"))
582+
.expect("error reloading `EnvFilter` for console_logger")
583+
}
584+
if matches.verbose {
585+
console_filter
586+
.modify(|it| *it = EnvFilter::new("rustup=DEBUG"))
587+
.expect("error reloading `EnvFilter` for console_logger")
590588
}
591589
}
592590

src/process.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use anyhow::{Context, Result};
1717
use tracing::subscriber::DefaultGuard;
1818
#[cfg(feature = "test")]
1919
use tracing_subscriber::util::SubscriberInitExt;
20+
#[cfg(feature = "test")]
21+
use tracing_subscriber::{reload::Handle, EnvFilter, Registry};
2022

2123
pub mod filesource;
2224
pub mod terminalsource;
@@ -177,6 +179,7 @@ impl Default for OsProcess {
177179
#[cfg(feature = "test")]
178180
pub struct TestProcess {
179181
pub process: Process,
182+
pub console_filter: Handle<EnvFilter, Registry>,
180183
_guard: DefaultGuard, // guard is dropped at the end of the test
181184
}
182185

@@ -230,10 +233,11 @@ impl TestProcess {
230233
impl From<TestContext> for TestProcess {
231234
fn from(inner: TestContext) -> Self {
232235
let inner = Process::TestProcess(inner);
233-
let guard = crate::cli::log::tracing_subscriber(&inner).0.set_default();
236+
let (tracing_subscriber, console_filter) = crate::cli::log::tracing_subscriber(&inner);
234237
Self {
235238
process: inner,
236-
_guard: guard,
239+
console_filter,
240+
_guard: tracing_subscriber.set_default(),
237241
}
238242
}
239243
}

src/test/mock/clitools.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,12 @@ impl Config {
790790
}
791791

792792
let tp = process::TestProcess::new(&*self.workdir.borrow(), &arg_strings, vars, "");
793-
let process_res =
794-
rustup_mode::main(tp.process.current_dir().unwrap(), &tp.process, None).await;
793+
let process_res = rustup_mode::main(
794+
tp.process.current_dir().unwrap(),
795+
&tp.process,
796+
tp.console_filter.clone(),
797+
)
798+
.await;
795799
// convert Err's into an ec
796800
let ec = match process_res {
797801
Ok(process_res) => process_res,

tests/suite/cli_rustup.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,7 @@ async fn rustup_stable_quiet() {
8484
8585
"
8686
),
87-
for_host!(
88-
r"info: syncing channel updates for 'stable-{0}'
89-
info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0)
90-
info: downloading component 'cargo'
91-
info: downloading component 'rust-docs'
92-
info: downloading component 'rust-std'
93-
info: downloading component 'rustc'
94-
info: removing previous version of component 'cargo'
95-
info: removing previous version of component 'rust-docs'
96-
info: removing previous version of component 'rust-std'
97-
info: removing previous version of component 'rustc'
98-
info: installing component 'cargo'
99-
info: installing component 'rust-docs'
100-
info: installing component 'rust-std'
101-
info: installing component 'rustc'
102-
info: cleaning up downloads & tmp directories
103-
"
104-
),
87+
"",
10588
)
10689
.await;
10790
}

0 commit comments

Comments
 (0)