Skip to content

Commit e802fa8

Browse files
committed
Fix tracing timer API so it works with updated tracing
1 parent 7a70970 commit e802fa8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/matrix-sdk-common/src/tracing_timer.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl TracingTimer {
8181
#[macro_export]
8282
macro_rules! timer {
8383
($level:expr, $string:expr) => {{
84-
static CALLSITE: tracing::callsite::DefaultCallsite = tracing::callsite2! {
84+
static __CALLSITE: tracing::callsite::DefaultCallsite = tracing::callsite2! {
8585
name: tracing::__macro_support::concat!(
8686
"event ",
8787
file!(),
@@ -94,7 +94,7 @@ macro_rules! timer {
9494
fields: []
9595
};
9696

97-
$crate::tracing_timer::TracingTimer::new_debug(&CALLSITE, $string.into(), $level)
97+
$crate::tracing_timer::TracingTimer::new_debug(&__CALLSITE, $string.into(), $level)
9898
}};
9999

100100
($string:expr) => {
@@ -109,8 +109,14 @@ mod tests {
109109
async fn test_timer_name() {
110110
use tracing::{span, Level};
111111

112+
if std::env::var("RUST_LOG").is_err() {
113+
std::env::set_var("RUST_LOG", "trace");
114+
}
115+
112116
tracing_subscriber::fmt::init();
113117

118+
tracing::warn!("Starting test...");
119+
114120
mod time123 {
115121
pub async fn run() {
116122
let _timer_guard = timer!(tracing::Level::DEBUG, "test");
@@ -128,6 +134,8 @@ mod tests {
128134

129135
let _timer_guard = timer!("in span");
130136
tokio::time::sleep(instant::Duration::from_millis(256)).await;
137+
138+
tracing::warn!("Test about to finish.");
131139
// Displays: 2023-08-25T15:18:31.427070Z DEBUG le 256ms span:
132140
// matrix_sdk_common::tracing_timer::tests: in span finished in 257ms
133141
}

0 commit comments

Comments
 (0)