Skip to content

Commit 919b0e9

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

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
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,7 +109,9 @@ mod tests {
109109
async fn test_timer_name() {
110110
use tracing::{span, Level};
111111

112-
tracing_subscriber::fmt::init();
112+
tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).init();
113+
114+
tracing::warn!("Starting test...");
113115

114116
mod time123 {
115117
pub async fn run() {
@@ -128,6 +130,8 @@ mod tests {
128130

129131
let _timer_guard = timer!("in span");
130132
tokio::time::sleep(instant::Duration::from_millis(256)).await;
133+
134+
tracing::warn!("Test about to finish.");
131135
// Displays: 2023-08-25T15:18:31.427070Z DEBUG le 256ms span:
132136
// matrix_sdk_common::tracing_timer::tests: in span finished in 257ms
133137
}

0 commit comments

Comments
 (0)