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

question: is valuable expected to work with tracing macros? #115

Closed
OliverNChalk opened this issue May 14, 2023 · 1 comment
Closed

question: is valuable expected to work with tracing macros? #115

OliverNChalk opened this issue May 14, 2023 · 1 comment

Comments

@OliverNChalk
Copy link

I was expecting valuable to work out of the box with tracing's macros (info, debug etc). However, I get an issue saying Value is not implemented for my type (i.e. there is no blanket implementation covering all types that implement Valuable). This currently seems like the only way to make tracing happy:

for (service, old_state) in removed {
    info!(service = &service as &dyn Valuable,"Service unit removed");
    self.service_state.remove(&service);
}

Please let me know if this was an oversight, or if there's a fundamental limitation preventing the compiler from auto-coercing my type (RemoteServiceId) that implements Valuable to Value?

@fluffysquirrels
Copy link

First you need to enable the tracing_unstable rustc flag and the valuable feature in the tracing crate. Ref.

Then you need to call .as_value() on the value before using a tracing macro, e.g.:

tracing::info!(service = service.as_value(), "Service unit removed");

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

No branches or pull requests

2 participants