Skip to content

chore: Remove usage of deprecated tracing-subscriber APIs #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ fn indent_block_with_lines(
}
}
}
buf.push_str(&lines[0]);
buf.push_str(lines[0]);
buf.push('\n');

// add the rest of the indentation, since we don't want to draw horizontal lines
Expand Down
25 changes: 15 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,12 @@ where
Ok(())
}

fn write_span_info<S: Subscriber + for<'span> LookupSpan<'span> + fmt::Debug>(
&self,
id: &tracing::Id,
ctx: &Context<S>,
style: SpanMode,
) {
fn write_span_info<S>(&self, id: &tracing::Id, ctx: &Context<S>, style: SpanMode)
where
S: Subscriber + for<'span> LookupSpan<'span> + fmt::Debug,
{
let span = ctx
.span(&id)
.span(id)
.expect("in on_enter/on_exit but span does not exist");
let ext = span.extensions();
let data = ext.get::<Data>().expect("span does not have data");
Expand All @@ -223,6 +221,9 @@ where
let bufs = &mut *guard;
let mut current_buf = &mut bufs.current_buf;

// todo(david): i'm going to keep this for a bit since there's an odd discrepancy in counting
// that i don't want to resolve rn lol
#[allow(deprecated)]
let indent = ctx.scope().count();

if self.config.verbose_entry || matches!(style, SpanMode::Open { .. } | SpanMode::Event) {
Expand Down Expand Up @@ -280,10 +281,11 @@ where
let span = ctx.span(id).expect("in new_span but span does not exist");
span.extensions_mut().insert(data);
if self.config.verbose_exit {
if let Some(span) = ctx.scope().last() {
if let Some(span) = span.parent() {
self.write_span_info(&span.id(), &ctx, SpanMode::PreOpen);
}
}

self.write_span_info(
id,
&ctx,
Expand All @@ -301,7 +303,9 @@ where
// printing the indentation
let indent = if ctx.current_span().id().is_some() {
// size hint isn't implemented on Scope.
ctx.scope().count()
ctx.event_scope(event)
.expect("Unable to get span scope; this is a bug")
.count()
} else {
0
};
Expand Down Expand Up @@ -378,8 +382,9 @@ where
verbose: self.config.verbose_exit,
},
);

if self.config.verbose_exit {
if let Some(span) = ctx.scope().last() {
if let Some(span) = ctx.span(&id).and_then(|span| span.parent()) {
self.write_span_info(&span.id(), &ctx, SpanMode::PostClose);
}
}
Expand Down