Skip to content
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

subscriber: expose access to event scope in FmtContext #1728

Merged
merged 1 commit into from Nov 19, 2021

Commits on Nov 19, 2021

  1. subscriber: expose access to event scope in FmtContext

    Currently, `tracing_subscriber::fmt`'s `FmtContext` type is missing the
    `span_scope`, `event_span`, and `event_scope` methods that `Context`
    provides. This is a shame; these will make it much easier for users
    implementing formatters to iterate over the scope of the event being
    formatted correctly. We should expose those methods.
    
    This branch adds new methods to `FmtContext`, most of which forward to
    the similarly-named `Context` methods. However, because a `FmtContext`
    is only constructed when formatting an event, we can also make the event
    scope methods a little more ergonomic by storing a ref to the span being
    formatted and automatically passing it to `Context::event_scope` and
    `Context::event_span`. This means the `FmtContext` can just always return
    the current event's scope without the user having to pass it in.
    hawkw committed Nov 19, 2021
    Copy the full SHA
    765182d View commit details
    Browse the repository at this point in the history