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

fmt: weird formatting with targets disabled #476

Closed
hawkw opened this issue Dec 18, 2019 · 0 comments · Fixed by #481
Closed

fmt: weird formatting with targets disabled #476

hawkw opened this issue Dec 18, 2019 · 0 comments · Fixed by #481
Labels
crate/fmt Related to the `tracing-fmt` crate good first issue Good for newcomers kind/bug Something isn't working

Comments

@hawkw
Copy link
Member

hawkw commented Dec 18, 2019

Bug Report

Crates

  • tracing-subscriber

Description

When configuring a formatter with

    .with_target(false)

events are formatted with a second space and colon following the span context, like this:
Screen Shot 2019-12-18 at 1 11 08 PM

This doesn't look great. We should fix it.

The issue is in this code:

write!(
writer,
"{} {}{}: ",
fmt_level,
fmt_ctx,
if self.display_target {
meta.target()
} else {
""
}
)?;

Notice how the : is part of the format string, so it's always output, even when we don't print a target.

We should change this so that when display_targets is not set, we don't include the : . We could do that by putting the if around the write! macro, instead, and having two separate format specs depending on whether or not we're including a target.

@hawkw hawkw added kind/bug Something isn't working good first issue Good for newcomers crate/fmt Related to the `tracing-fmt` crate labels Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/fmt Related to the `tracing-fmt` crate good first issue Good for newcomers kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant