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: fix leading comma with Pretty formatter #1833

Merged
merged 1 commit into from
Jan 13, 2022

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Jan 13, 2022

Motivation

PR #1661 introduced a regression with the Pretty formatter: the
PrettyVisitor type was accidentally changed from being
constructed with is_empty: true to being constructed with
is_empty: false This means that when visiting a set of span fields,
we emit a leading , before the first field, which looks quite bad.

Solution

This branch changes it back, and now the output looks nice again. :)

Before

  2022-01-13T17:09:04.772411Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with , yak: 2
    in fmt_pretty::yak_shave::shaving_yaks with , yaks: 3

After

  2022-01-13T17:10:28.472525Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with yak: 1
    in fmt_pretty::yak_shave::shaving_yaks with yaks: 3,

Fixes: #1832

PR #1661 introduced a regression with the `Pretty` formatter: the
`PrettyVisitor` type was [accidentally changed][1] from being
constructed with `is_empty: true` to being constructed with `is_empty:
false` This means that when visiting a set of span fields, we emit a
leading `, ` _before_ the first field, which looks quite bad.

This branch changes it back, and now the output looks nice again. :)

[1]: 937c5d7#diff-a27a4c3564a0c2f1b7af32be0f9eec25ddfbe8b4c2be8d74e84d874b919b393bR227
@hawkw hawkw requested a review from a team as a code owner January 13, 2022 17:16
Copy link
Member

@davidbarsky davidbarsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...whoops.

@hawkw hawkw merged commit 67c21fa into master Jan 13, 2022
@hawkw hawkw deleted the eliza/make-pretty-pretty branch January 13, 2022 17:30
hawkw added a commit that referenced this pull request Jan 14, 2022
## Motivation

PR #1661 introduced a regression with the `Pretty` formatter: the
`PrettyVisitor` type was [accidentally changed][1] from being
constructed with `is_empty: true` to being constructed with 
`is_empty: false` This means that when visiting a set of span fields,
we emit a leading `, ` _before_ the first field, which looks quite bad.

## Solution

This branch changes it back, and now the output looks nice again. :)

### Before

```
  2022-01-13T17:09:04.772411Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with , yak: 2
    in fmt_pretty::yak_shave::shaving_yaks with , yaks: 3
```

### After

```
  2022-01-13T17:10:28.472525Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with yak: 1
    in fmt_pretty::yak_shave::shaving_yaks with yaks: 3,
```

Fixes: #1832

[1]: 937c5d7#diff-a27a4c3564a0c2f1b7af32be0f9eec25ddfbe8b4c2be8d74e84d874b919b393bR227
hawkw added a commit that referenced this pull request Jan 14, 2022
## Motivation

PR #1661 introduced a regression with the `Pretty` formatter: the
`PrettyVisitor` type was [accidentally changed][1] from being
constructed with `is_empty: true` to being constructed with 
`is_empty: false` This means that when visiting a set of span fields,
we emit a leading `, ` _before_ the first field, which looks quite bad.

## Solution

This branch changes it back, and now the output looks nice again. :)

### Before

```
  2022-01-13T17:09:04.772411Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with , yak: 2
    in fmt_pretty::yak_shave::shaving_yaks with , yaks: 3
```

### After

```
  2022-01-13T17:10:28.472525Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with yak: 1
    in fmt_pretty::yak_shave::shaving_yaks with yaks: 3,
```

Fixes: #1832

[1]: 937c5d7#diff-a27a4c3564a0c2f1b7af32be0f9eec25ddfbe8b4c2be8d74e84d874b919b393bR227
hawkw added a commit that referenced this pull request Jan 14, 2022
# 0.3.6 (Jan 14, 2022)

This release adds configuration options to `tracing_subscriber::fmt` to
log source code locations for events.
### Added

- **fmt**: Added `with_file` and `with_line_number` configuration
  methods to `fmt::Format`, `fmt::SubscriberBuilder`, and `fmt::Layer`
  ([#1773])

### Fixed

- **fmt**: Removed incorrect leading comma from span fields with the
  `Pretty` formatter ([#1833])

### Deprecated

- **fmt**: Deprecated `Pretty::with_source_location`, as it can now be
  replaced by the more general `Format`, `SubscriberBuilder`, and
  `Layer` methods ([#1773])

Thanks to new contributor @renecouto for contributing to this release!

[#1773]: #1773
[#1833]: #1833
hawkw added a commit that referenced this pull request Jan 14, 2022
# 0.3.6 (Jan 14, 2022)

This release adds configuration options to `tracing_subscriber::fmt` to
log source code locations for events.
### Added

- **fmt**: Added `with_file` and `with_line_number` configuration
  methods to `fmt::Format`, `fmt::SubscriberBuilder`, and `fmt::Layer`
  ([#1773])

### Fixed

- **fmt**: Removed incorrect leading comma from span fields with the
  `Pretty` formatter ([#1833])

### Deprecated

- **fmt**: Deprecated `Pretty::with_source_location`, as it can now be
  replaced by the more general `Format`, `SubscriberBuilder`, and
  `Layer` methods ([#1773])

Thanks to new contributor @renecouto for contributing to this release!

[#1773]: #1773
[#1833]: #1833
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request May 22, 2024
# 0.3.6 (Jan 14, 2022)

This release adds configuration options to `tracing_subscriber::fmt` to
log source code locations for events.
### Added

- **fmt**: Added `with_file` and `with_line_number` configuration
  methods to `fmt::Format`, `fmt::SubscriberBuilder`, and `fmt::Layer`
  ([tokio-rs#1773])

### Fixed

- **fmt**: Removed incorrect leading comma from span fields with the
  `Pretty` formatter ([tokio-rs#1833])

### Deprecated

- **fmt**: Deprecated `Pretty::with_source_location`, as it can now be
  replaced by the more general `Format`, `SubscriberBuilder`, and
  `Layer` methods ([tokio-rs#1773])

Thanks to new contributor @renecouto for contributing to this release!

[tokio-rs#1773]: tokio-rs#1773
[tokio-rs#1833]: tokio-rs#1833
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pretty formatter emits a leading comma in span fields
2 participants