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

Remove brackets and message field name from rendered message #19

Merged
merged 1 commit into from
Sep 28, 2020

Conversation

oli-obk
Copy link
Collaborator

@oli-obk oli-obk commented Aug 18, 2020

I found some other code that was also matching on the message name and skipped printing it. I extended it to the code here, but I was unable to figure out how the other code is invoked or how to trigger it, since it looks to me like it would render "foo" instead of foo, because it's using Debug printing which renders quotes around strings.

Here's a rendered version:

Screenshot from 2020-08-18 18-29-33

As text:

1:main│ ├┐basic::server host="localhost", port=8080
1:main│ │└┐basic::foomp 42 <- format string, normal_var=43
1:main│ │ ├─0ms ERROR basic hello
1:main│ │┌┘basic::foomp 42 <- format string, normal_var=43
1:main│ ├┘basic::server host="localhost", port=8080

fixes #18

@davidbarsky
Copy link
Owner

Few notes:

  • I don't think there's much that we can do about "foo" being rendered instead of foo. That might need to be fixed in tokio-rs/tracing's macros.
  • I think that removing {message="..."} is unambigously the right choice.
  • I'm a fan of {} being dropped from non-message fields. I'd like to keep that and introduce a toggle.

Speaking of toggles, how do you feel about not merging this PR and instead exposing some pre-configured event and field formatters from tracing_subscriber::fmt? It might reduce some of the complexity in this crate. That said, if this change unblocks rust-lang/rust#75143 (comment), I'll be happy to merge this and release it as 0.2.beta-1.

@oli-obk
Copy link
Collaborator Author

oli-obk commented Aug 20, 2020

I tried figuring out the formatting infrastructure in tracing_subscriber::fmt for two hours and have not gotten much further with understanding the parts. I would indeed prefer to merge (potentially with more toggles).

* I'm a fan of `{}` being dropped from non-`message` fields. I'd like to keep that and introduce a toggle.

You mean "not a fan"? so the default should be to keep it?

* I think that removing `{message="..."}` is unambigously the right choice.

do we keep the {} around it without the flag from the non-message fields?

* I don't think there's much that we can do about `"foo"` being rendered instead of `foo`. That might need to be fixed in tokio-rs/tracing's macros.

this all works out great, we do get foo.

@davidbarsky
Copy link
Owner

I tried figuring out the formatting infrastructure in tracing_subscriber::fmt for two hours and have not gotten much further with understanding the parts. I would indeed prefer to merge (potentially with more toggles).

That's fair, their documentation and organization can be improved. Sorry to send you on a wild goose chase. I can make this a feature for 0.2.

You mean "not a fan"? so the default should be to keep it?
do we keep the {} around it without the flag from the non-message fields?

Sorry, that was confusing. Oncall's been busy, so I edited that poorly. I was trying to say that treating the message field as a special case such that {message="..."} is no longer rendered is the right choice. However, I'd like to have the current curly bracket treatment for all non-message fields available behind a toggle. How do you feel about that?

  • I don't think there's much that we can do about "foo" being rendered instead of foo. That might need to be fixed in tokio-rs/tracing's macros.
    this all works out great, we do get foo.

Okay!

@oli-obk
Copy link
Collaborator Author

oli-obk commented Sep 19, 2020

I updated the commit so the brackets can get enabled again if desired. We should probably merge the ui test PR before this so we can use it to review this PR 😆

@davidbarsky
Copy link
Owner

davidbarsky commented Sep 19, 2020

I updated the commit so the brackets can get enabled again if desired.

Thank you!

We should probably merge the ui test PR before this so we can use it to review this PR 😆

Eager to try it out in reviewing this PR! 😄

@oli-obk
Copy link
Collaborator Author

oli-obk commented Sep 20, 2020

I set the stderr example to showcase that the with_bracketed_fields flag actually works properly (which immediately caught a bug 😆 )

Copy link
Owner

@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.

Sorry for forgetting about this! Looks good to me; we can fix this in subsequent PRs.

@davidbarsky davidbarsky merged commit b7a839f into davidbarsky:main Sep 28, 2020
@oli-obk oli-obk deleted the visual_redundancy branch September 28, 2020 16:39
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.

Remove possibly redundant information from span info
2 participants