Skip to content

Commit

Permalink
subscriber: Add a public current_span() method for FmtContext (#1290
Browse files Browse the repository at this point in the history
)

This backports PR #1290 from `master`.
  • Loading branch information
Folyd authored and hawkw committed Mar 12, 2021
1 parent 14d11eb commit 544da6b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tracing-subscriber/src/fmt/fmt_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use format::{FmtSpan, TimingDisplay};
use std::{any::TypeId, cell::RefCell, fmt, io, marker::PhantomData, ops::Deref, time::Instant};
use tracing_core::{
field,
span::{Attributes, Id, Record},
span::{Attributes, Current, Id, Record},
Event, Metadata, Subscriber,
};

Expand Down Expand Up @@ -856,6 +856,11 @@ where
self.ctx.scope()
}

/// Returns the current span for this formatter.
pub fn current_span(&self) -> Current {
self.ctx.current_span()
}

/// Returns the [field formatter] configured by the subscriber invoking
/// `format_event`.
///
Expand Down

0 comments on commit 544da6b

Please sign in to comment.