@@ -20,7 +20,6 @@ use rs_tracing::{
20
20
close_trace_file, close_trace_file_internal, open_trace_file, trace_to_file_internal,
21
21
} ;
22
22
23
- use rustup:: cli:: common;
24
23
use rustup:: cli:: proxy_mode;
25
24
use rustup:: cli:: rustup_mode;
26
25
#[ cfg( windows) ]
@@ -30,6 +29,7 @@ use rustup::currentprocess::{process, varsource::VarSource, with, OSProcess};
30
29
use rustup:: env_var:: RUST_RECURSION_COUNT_MAX ;
31
30
use rustup:: is_proxyable_tools;
32
31
use rustup:: utils:: utils;
32
+ use rustup:: { cli:: common, currentprocess:: filesource:: StderrSource } ;
33
33
34
34
fn main ( ) {
35
35
#[ cfg( windows) ]
@@ -61,13 +61,15 @@ fn maybe_trace_rustup() -> Result<utils::ExitCode> {
61
61
trace:: { self , Sampler } ,
62
62
Resource ,
63
63
} ;
64
- use tracing_subscriber:: { layer:: SubscriberExt , EnvFilter , Registry } ;
64
+ use tracing_subscriber:: { fmt, layer:: SubscriberExt , EnvFilter , Registry } ;
65
+
66
+ let curr_process = process ( ) ;
65
67
66
68
// Background submission requires a runtime, and since we're probably
67
69
// going to want async eventually, we just use tokio.
68
70
let threaded_rt = tokio:: runtime:: Runtime :: new ( ) ?;
69
71
70
- let result = threaded_rt. block_on ( async {
72
+ let result = threaded_rt. block_on ( async move {
71
73
global:: set_text_map_propagator ( TraceContextPropagator :: new ( ) ) ;
72
74
let tracer = opentelemetry_otlp:: new_pipeline ( )
73
75
. tracing ( )
@@ -87,7 +89,14 @@ fn maybe_trace_rustup() -> Result<utils::ExitCode> {
87
89
. install_batch ( opentelemetry_sdk:: runtime:: Tokio ) ?;
88
90
let env_filter = EnvFilter :: try_from_default_env ( ) . unwrap_or ( EnvFilter :: new ( "INFO" ) ) ;
89
91
let telemetry = tracing_opentelemetry:: layer ( ) . with_tracer ( tracer) ;
90
- let subscriber = Registry :: default ( ) . with ( env_filter) . with ( telemetry) ;
92
+ let subscriber = Registry :: default ( )
93
+ . with (
94
+ fmt:: layer ( )
95
+ . with_ansi ( curr_process. stderr ( ) . is_a_tty ( ) )
96
+ . with_writer ( move || curr_process. stderr ( ) ) ,
97
+ )
98
+ . with ( env_filter)
99
+ . with ( telemetry) ;
91
100
tracing:: subscriber:: set_global_default ( subscriber) ?;
92
101
let result = run_rustup ( ) ;
93
102
// We're tracing, so block until all spans are exported.
0 commit comments