@@ -10,6 +10,7 @@ use clap::{builder::PossibleValue, Args, CommandFactory, Parser, Subcommand, Val
10
10
use clap_complete:: Shell ;
11
11
use itertools:: Itertools ;
12
12
use tracing:: { info, trace, warn} ;
13
+ use tracing_subscriber:: { reload:: Handle , EnvFilter , Registry } ;
13
14
14
15
use crate :: {
15
16
cli:: {
@@ -68,12 +69,12 @@ fn handle_epipe(res: Result<utils::ExitCode>) -> Result<utils::ExitCode> {
68
69
after_help = RUSTUP_HELP ,
69
70
) ]
70
71
struct Rustup {
71
- /// Enable verbose output
72
- #[ arg( short, long) ]
72
+ /// Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is unset
73
+ #[ arg( short, long, overrides_with = "quiet" ) ]
73
74
verbose : bool ,
74
75
75
- /// Disable progress output
76
- #[ arg( short, long, conflicts_with = "verbose" ) ]
76
+ /// Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is unset
77
+ #[ arg( short, long, overrides_with = "verbose" ) ]
77
78
quiet : bool ,
78
79
79
80
/// Release channel (e.g. +stable) or custom toolchain to set override
@@ -532,7 +533,11 @@ enum SetSubcmd {
532
533
}
533
534
534
535
#[ tracing:: instrument( level = "trace" , fields( args = format!( "{:?}" , process. args_os( ) . collect:: <Vec <_>>( ) ) ) ) ]
535
- pub async fn main ( current_dir : PathBuf , process : & Process ) -> Result < utils:: ExitCode > {
536
+ pub async fn main (
537
+ current_dir : PathBuf ,
538
+ process : & Process ,
539
+ console_filter : Handle < EnvFilter , Registry > ,
540
+ ) -> Result < utils:: ExitCode > {
536
541
self_update:: cleanup_self_updater ( process) ?;
537
542
538
543
use clap:: error:: ErrorKind :: * ;
@@ -570,6 +575,19 @@ pub async fn main(current_dir: PathBuf, process: &Process) -> Result<utils::Exit
570
575
}
571
576
} ;
572
577
578
+ if process. var ( "RUSTUP_LOG" ) . is_err ( ) {
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" )
588
+ }
589
+ }
590
+
573
591
let cfg = & mut common:: set_globals ( current_dir, matches. quiet , process) ?;
574
592
575
593
if let Some ( t) = & matches. plus_toolchain {
0 commit comments