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

Implement Value for more types #726

Open
jonhoo opened this issue May 21, 2020 · 3 comments
Open

Implement Value for more types #726

jonhoo opened this issue May 21, 2020 · 3 comments
Labels
crate/core Related to the `tracing-core` crate kind/feature New feature or request

Comments

@jonhoo
Copy link
Contributor

jonhoo commented May 21, 2020

tracing_core::Value is currently missing implementations for some pretty common types from the standard library. The ones I ran into:

  • f32 and f64
  • String — this will (I think) move the type, so it may not do what people want, but it'll give us &String. If we could implement for AsRef<str>, now that would be neat. But may not work because of coherence.
  • Cow<T> where T: Value (though this may require a MSRV bump for this)

Of course, it's possible to use %/Display for these, but it'd be nice if one didn't have to.

@hawkw hawkw added crate/core Related to the `tracing-core` crate kind/feature New feature or request labels May 21, 2020
@pickfire
Copy link

I ran into Path and PathBuf as well, supporting Display would be good.

@Veetaha
Copy link
Contributor

Veetaha commented Aug 27, 2021

I suggest at least starting adding an impl for String, because it is cumbersome to write all the time

let owned_string: String = ...;

info!(owned_string = onwed_string.as_str(), "foo");

// or less-efficient, but less verbose:

info!(%owned_string, "foo");

@poelzi
Copy link

poelzi commented Apr 6, 2023

Especially working with Path is very cumbersum with no support for &Path and &OsString

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/core Related to the `tracing-core` crate kind/feature New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants