Skip to content

Commit d398164

Browse files
authored
fix: Don't crash if ctx is in a span but event isn't (#55)
This can occur when there are active spans, but all of the active spans are filtered out by a per-layer filter, so don't show up to us.
1 parent 8f9f96d commit d398164

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,10 @@ where
307307
let mut event_buf = &mut bufs.current_buf;
308308

309309
// printing the indentation
310-
let indent = if ctx.current_span().id().is_some() {
311-
// size hint isn't implemented on Scope.
312-
ctx.event_scope(event)
313-
.expect("Unable to get span scope; this is a bug")
314-
.count()
315-
} else {
316-
0
317-
};
310+
let indent = ctx
311+
.event_scope(event)
312+
.map(|scope| scope.count())
313+
.unwrap_or(0);
318314

319315
// check if this event occurred in the context of a span.
320316
// if it has, get the start time of this span.

0 commit comments

Comments
 (0)