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

Add a Display variant to Value. #85

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

chanks
Copy link

@chanks chanks commented Feb 7, 2022

Per discussion in Discord - @hawkw saw this as a desirable feature, to support emitting generic text in tracing without requiring that there be an underlying &str value.

Note that I used the Display output directly in the Debug impl for Value::Display - this seems a little awkward, but I'm not sure of a better option.

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! I think we probably want to make the as_display method also return a Display trait object for primitive types that implement Display, so I would probably change that before merging this.

@@ -104,6 +125,7 @@ macro_rules! value {
$(#[$attrs])*
$variant(v) => fmt::Debug::fmt(v, fmt),
)*
Display(d) => d.fmt(fmt),
Copy link
Member

Choose a reason for hiding this comment

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

i wonder if we want to quote this while debug printing it? it's essentially a different way of recording a string, and strings are quoted in fmt::Debug. @carllerche WDYT?

valuable/src/value.rs Show resolved Hide resolved
hawkw added 5 commits March 3, 2022 09:47
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This indicates that `Display` values are essentially being recorded as
strings, rather than structured data, in the `Debug` output.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@hawkw
Copy link
Member

hawkw commented Mar 7, 2022

I opened chanks#1 to suggest a few potential changes to this PR. @chanks, please take a look and feel free to merge that branch into yours if you like! I would like to get this merged soon, if you have the time. Otherwise, I'm also happy to take it across the finish line, if you're busy.

@chanks chanks requested a review from hawkw March 8, 2022 00:20
@chanks
Copy link
Author

chanks commented Mar 8, 2022

Updated with your changes, thank you!

@hawkw hawkw requested a review from carllerche March 8, 2022 18:20
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

this looks good to me, thanks for applying the changes i suggested!

it would be nice to get an approval from @carllerche or @taiki-e before merging this, since i wrote some of the code in it :)

valuable/src/value.rs Outdated Show resolved Hide resolved
chanks and others added 3 commits March 8, 2022 14:53
Comment on lines +773 to +778
// XXX(eliza): this, sadly, does not work for `Path`s; the
// only way to return them as a `Display` impl is
// `Path::display`, which creates a value owned by _this_
// function; we can't return that as a trait object because
// we're borrowing it from the function's scope rather than
// from the value itself.
Copy link
Member

Choose a reason for hiding this comment

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

#43 (comment) is one of alternatives that can handle this case well.

@taiki-e
Copy link
Member

taiki-e commented Mar 10, 2022

I think it would be preferable to compare this with the approach discussed in #43 before merging. (having both is confusing.)

@hawkw
Copy link
Member

hawkw commented Aug 18, 2022

This is going to be a blocker for fully replacing tracing's value system with valuable, so it would be nice to get this one figured out...

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.

3 participants