Skip to content

Commit a5d88d9

Browse files
committed
refator(common): Rename TracingTimer::new_debug.
This patch renames `TracingTiming::new_debug` to `new`. The documentation claims it sets the log level to `debug` while the `level` is actually an argument of the constructor. It's then wrong, and the constructor must be renamed.
1 parent 7a87580 commit a5d88d9

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl std::fmt::Debug for TracingTimer {
3333

3434
impl Drop for TracingTimer {
3535
fn drop(&mut self) {
36-
let message = format!("`{}` finished in {:?}", self.id, self.start.elapsed());
36+
let message = format!("_{}_ finished in {:?}", self.id, self.start.elapsed());
3737

3838
let enabled = tracing::level_enabled!(self.level) && {
3939
let interest = self.callsite.interest();
@@ -62,12 +62,8 @@ impl Drop for TracingTimer {
6262
}
6363

6464
impl TracingTimer {
65-
/// Create a new `TracingTimer` at the `debug` log level.
66-
pub fn new_debug(
67-
callsite: &'static DefaultCallsite,
68-
id: String,
69-
level: tracing::Level,
70-
) -> Self {
65+
/// Create a new `TracingTimer`.
66+
pub fn new(callsite: &'static DefaultCallsite, id: String, level: tracing::Level) -> Self {
7167
Self { id, callsite, start: Instant::now(), level }
7268
}
7369
}
@@ -111,7 +107,7 @@ macro_rules! timer {
111107
fields: []
112108
};
113109

114-
$crate::tracing_timer::TracingTimer::new_debug(&__CALLSITE, $string.into(), $level)
110+
$crate::tracing_timer::TracingTimer::new(&__CALLSITE, $string.into(), $level)
115111
}};
116112

117113
($string:expr) => {
@@ -133,7 +129,7 @@ mod tests {
133129
let _timer_guard = timer!(tracing::Level::DEBUG, "test");
134130
tokio::time::sleep(ruma::time::Duration::from_millis(123)).await;
135131
// Displays: 2023-08-25T15:18:31.169498Z DEBUG
136-
// matrix_sdk_common::tracing_timer::tests: test finished in
132+
// matrix_sdk_common::tracing_timer::tests: _test_ finished in
137133
// 124ms
138134
}
139135
}

0 commit comments

Comments
 (0)