@@ -37,11 +37,6 @@ use std::{
37
37
time:: { Duration , Instant } ,
38
38
} ;
39
39
40
- #[ cfg( all( feature = "direct-log" , not( feature = "tracing" ) ) ) ]
41
- use log:: warn;
42
- #[ cfg( feature = "tracing" ) ]
43
- use tracing:: warn;
44
-
45
40
#[ cfg( any( unix, windows) ) ]
46
41
mod cmsg;
47
42
@@ -58,6 +53,29 @@ mod imp;
58
53
#[ path = "fallback.rs" ]
59
54
mod imp;
60
55
56
+ #[ allow( unused_imports, unused_macros) ]
57
+ mod log {
58
+ #[ cfg( all( feature = "direct-log" , not( feature = "tracing" ) ) ) ]
59
+ pub ( crate ) use log:: { debug, error, info, trace, warn} ;
60
+
61
+ #[ cfg( feature = "tracing" ) ]
62
+ pub ( crate ) use tracing:: { debug, error, info, trace, warn} ;
63
+
64
+ #[ cfg( not( any( feature = "direct-log" , feature = "tracing" ) ) ) ]
65
+ mod no_op {
66
+ macro_rules! trace ( ( $( $tt: tt) * ) => { { } } ) ;
67
+ macro_rules! debug ( ( $( $tt: tt) * ) => { { } } ) ;
68
+ macro_rules! info ( ( $( $tt: tt) * ) => { { } } ) ;
69
+ macro_rules! log_warn ( ( $( $tt: tt) * ) => { { } } ) ;
70
+ macro_rules! error ( ( $( $tt: tt) * ) => { { } } ) ;
71
+
72
+ pub ( crate ) use { debug, error, info, log_warn as warn, trace} ;
73
+ }
74
+
75
+ #[ cfg( not( any( feature = "direct-log" , feature = "tracing" ) ) ) ]
76
+ pub ( crate ) use no_op:: * ;
77
+ }
78
+
61
79
pub use imp:: UdpSocketState ;
62
80
63
81
/// Number of UDP packets to send/receive at a time
@@ -139,7 +157,7 @@ fn log_sendmsg_error(
139
157
let last_send_error = & mut * last_send_error. lock ( ) . expect ( "poisend lock" ) ;
140
158
if now. saturating_duration_since ( * last_send_error) > IO_ERROR_LOG_INTERVAL {
141
159
* last_send_error = now;
142
- warn ! (
160
+ log :: warn!(
143
161
"sendmsg error: {:?}, Transmit: {{ destination: {:?}, src_ip: {:?}, enc: {:?}, len: {:?}, segment_size: {:?} }}" ,
144
162
err, transmit. destination, transmit. src_ip, transmit. ecn, transmit. contents. len( ) , transmit. segment_size) ;
145
163
}
0 commit comments