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

backport recent subscriber and attributes changes #1300

Merged
merged 7 commits into from
Mar 12, 2021
Merged

Commits on Mar 12, 2021

  1. subscriber: use struct update syntax when constructing from self (#…

    …1289)
    
    This backports #1289 from `master`.
    
    This PR aims to remove a lot of initializer boilerplate code by adopting
    the`struct update syntax.  If the [RFC 2528]  gets merged and
    implemented, we can remove more. 😸
    
    [RFC 2528]: rust-lang/rfcs#2528
    Folyd authored and hawkw committed Mar 12, 2021
    Configuration menu
    Copy the full SHA
    94ba9c0 View commit details
    Browse the repository at this point in the history
  2. subscriber: remove unnecessary transparent attribute (#1282)

    As far as I can tell, we are not relying on transparency anywhere, so
    using this rather refined feature here is confusing.
    matklad authored and hawkw committed Mar 12, 2021
    Configuration menu
    Copy the full SHA
    e754ee9 View commit details
    Browse the repository at this point in the history
  3. subscriber: Add a public current_span() method for FmtContext (#1290

    )
    
    This backports PR #1290 from `master`.
    Folyd authored and hawkw committed Mar 12, 2021
    Configuration menu
    Copy the full SHA
    96ad780 View commit details
    Browse the repository at this point in the history
  4. attributes: fix #[instrument] skipping code when returning pinned f…

    …utures (#1297)
    
    This backports #1297 from `master`.
    
    Fixes #1296.
    
    I had forgotten to use all the input statements in #1228, so we would
    delete nearly all the statement of sync functions that return a boxed
    future :/
    nightmared authored and hawkw committed Mar 12, 2021
    Configuration menu
    Copy the full SHA
    a933bb7 View commit details
    Browse the repository at this point in the history
  5. subscriber: fix extra padding in pretty format (#1275)

    ## Motivation
    
    This fixes #1212, where extra padding was written when logging with the
    pretty formatter.
    
    ## Solution 
    
    With this change we only write padding when we actually decide to write
    a value but not when skipping a metadata value such as `log.file` or
    `log.line`
    lenaschoenburg authored and hawkw committed Mar 12, 2021
    Configuration menu
    Copy the full SHA
    73b472e View commit details
    Browse the repository at this point in the history
  6. subscriber: change FmtSpan to a combinable bitflag (#1277)

    This backports #1277 from `master`.
    
    Fixes #1136.
    
    Allows arbitrarily combining different FmtSpan events to listen to.
    
    Motivation
    ----------
    
    The idea is to allow any combination of `FmtSpan` options, such as the
    currently unachievable combination of `FmtSpan::NEW | FmtSpan::CLOSE`.
    
    Solution
    --------
    
    Make `FmtSpan` behave like a bitflag that can be combined using the
    bitwise or operator ( `|` ) while maintaining backward compatibility by
    keeping the same names for all existing presets and keeping the
    implementation details hidden.
    zicklag authored and hawkw committed Mar 12, 2021
    Configuration menu
    Copy the full SHA
    4ac4e8c View commit details
    Browse the repository at this point in the history
  7. subscriber: update pretty formatter for no ansi (#1240)

    This backports #1240 from `master`.
    
    * subscriber: update pretty formatter for no ansi
    
     ## Background
    
        Currently, when the `Pretty` event formatter is being used, it does
        not change its output when the `with_ansi` flag is set to false by
        the `CollectorBuilder`.
    
     ## Overview
    
        While this formatter is generally used in situations such as local
        development, where ANSI escape codes are more often acceptable,
        there are some situations in which this can lead to mangled output.
    
        This commit makes some minor changes to account for this `ansi` flag
        when formatting events using `Pretty`.
    
        Becuase ANSI codes were previously used to imply the event level
        using colors, this commit additionally modifies `Pretty` so that
        it respects `display_level` when formatting an event.
    
     ## Changes
    
        * Changes to `<Format<Pretty, T> as FormatEvent<C, N>>::format_event`
    
        * Add a `PrettyVisitor::ansi` boolean flag, used in its `Visit`
          implementation.
    
            * Add a new `PrettyVisitor::with_ansi` builder pattern method to
              facilitate this.
    
     ## Out of Scope
    
        One detail worth nothing is that this does not solve the problem of
        *fields* being formatted without ANSI codes. Configuring a
        subscriber using this snippet would still lead to bolded fields in
        parent spans.
    
    ```rust
    tracing_subscriber::fmt()
        .pretty()
        .with_ansi(false)
        .with_level(false)
        .with_max_level(tracing::Level::TRACE)
        .init();
    ```
    
        This can be worked around by using a different field formatter, via
        `.fmt_fields(tracing_subscriber::fmt::format::DefaultFields::new())`
        in the short-term.
    
        In the long-term, #658 is worth investigating further.
    
    Refs: #658
    katelyn martin authored and hawkw committed Mar 12, 2021
    Configuration menu
    Copy the full SHA
    19c08ca View commit details
    Browse the repository at this point in the history