@@ -8,8 +8,8 @@ use curl::easy::Easy;
8
8
use curl:: easy:: InfoType ;
9
9
use curl:: easy:: SslOpt ;
10
10
use curl:: easy:: SslVersion ;
11
- use log :: log ;
12
- use log :: Level ;
11
+ use tracing :: debug ;
12
+ use tracing :: trace ;
13
13
14
14
use crate :: util:: config:: SslVersionConfig ;
15
15
use crate :: util:: config:: SslVersionConfigRange ;
@@ -135,14 +135,19 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
135
135
136
136
if let Some ( true ) = http. debug {
137
137
handle. verbose ( true ) ?;
138
- log :: debug!( "{:#?}" , curl:: Version :: get( ) ) ;
138
+ tracing :: debug!( "{:#?}" , curl:: Version :: get( ) ) ;
139
139
handle. debug_function ( |kind, data| {
140
+ enum LogLevel {
141
+ Debug ,
142
+ Trace ,
143
+ }
144
+ use LogLevel :: * ;
140
145
let ( prefix, level) = match kind {
141
- InfoType :: Text => ( "*" , Level :: Debug ) ,
142
- InfoType :: HeaderIn => ( "<" , Level :: Debug ) ,
143
- InfoType :: HeaderOut => ( ">" , Level :: Debug ) ,
144
- InfoType :: DataIn => ( "{" , Level :: Trace ) ,
145
- InfoType :: DataOut => ( "}" , Level :: Trace ) ,
146
+ InfoType :: Text => ( "*" , Debug ) ,
147
+ InfoType :: HeaderIn => ( "<" , Debug ) ,
148
+ InfoType :: HeaderOut => ( ">" , Debug ) ,
149
+ InfoType :: DataIn => ( "{" , Trace ) ,
150
+ InfoType :: DataOut => ( "}" , Trace ) ,
146
151
InfoType :: SslDataIn | InfoType :: SslDataOut => return ,
147
152
_ => return ,
148
153
} ;
@@ -159,16 +164,18 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
159
164
} else if starts_with_ignore_case ( line, "set-cookie" ) {
160
165
line = "set-cookie: [REDACTED]" ;
161
166
}
162
- log ! ( level, "http-debug: {} {}" , prefix, line) ;
167
+ match level {
168
+ Debug => debug ! ( "http-debug: {prefix} {line}" ) ,
169
+ Trace => trace ! ( "http-debug: {prefix} {line}" ) ,
170
+ }
163
171
}
164
172
}
165
173
Err ( _) => {
166
- log ! (
167
- level,
168
- "http-debug: {} ({} bytes of data)" ,
169
- prefix,
170
- data. len( )
171
- ) ;
174
+ let len = data. len ( ) ;
175
+ match level {
176
+ Debug => debug ! ( "http-debug: {prefix} ({len} bytes of data)" ) ,
177
+ Trace => trace ! ( "http-debug: {prefix} ({len} bytes of data)" ) ,
178
+ }
172
179
}
173
180
}
174
181
} ) ?;
0 commit comments