@@ -81,7 +81,7 @@ impl TracingTimer {
81
81
#[ macro_export]
82
82
macro_rules! timer {
83
83
( $level: expr, $string: expr) => { {
84
- static CALLSITE : tracing:: callsite:: DefaultCallsite = tracing:: callsite2! {
84
+ static __CALLSITE : tracing:: callsite:: DefaultCallsite = tracing:: callsite2! {
85
85
name: tracing:: __macro_support:: concat!(
86
86
"event " ,
87
87
file!( ) ,
@@ -94,7 +94,7 @@ macro_rules! timer {
94
94
fields: [ ]
95
95
} ;
96
96
97
- $crate:: tracing_timer:: TracingTimer :: new_debug( & CALLSITE , $string. into( ) , $level)
97
+ $crate:: tracing_timer:: TracingTimer :: new_debug( & __CALLSITE , $string. into( ) , $level)
98
98
} } ;
99
99
100
100
( $string: expr) => {
@@ -109,8 +109,14 @@ mod tests {
109
109
async fn test_timer_name ( ) {
110
110
use tracing:: { span, Level } ;
111
111
112
+ if std:: env:: var ( "RUST_LOG" ) . is_err ( ) {
113
+ std:: env:: set_var ( "RUST_LOG" , "trace" ) ;
114
+ }
115
+
112
116
tracing_subscriber:: fmt:: init ( ) ;
113
117
118
+ tracing:: warn!( "Starting test..." ) ;
119
+
114
120
mod time123 {
115
121
pub async fn run ( ) {
116
122
let _timer_guard = timer ! ( tracing:: Level :: DEBUG , "test" ) ;
@@ -128,6 +134,8 @@ mod tests {
128
134
129
135
let _timer_guard = timer ! ( "in span" ) ;
130
136
tokio:: time:: sleep ( instant:: Duration :: from_millis ( 256 ) ) . await ;
137
+
138
+ tracing:: warn!( "Test about to finish." ) ;
131
139
// Displays: 2023-08-25T15:18:31.427070Z DEBUG le 256ms span:
132
140
// matrix_sdk_common::tracing_timer::tests: in span finished in 257ms
133
141
}
0 commit comments