Skip to content

Commit

Permalink
Implement Value for Valuable expose in tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-emotech committed Oct 1, 2021
1 parent f595d70 commit 5147657
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub struct Iter {
pub trait Visit {
/// Visits an arbitrary value from Valuable
#[cfg(feature = "valuable")]
fn record_value(&mut self, field: &Field, value: &(dyn valuable::Valuable)) {
fn record_value(&mut self, field: &Field, value: &dyn valuable::Valuable) {
self.record_debug(field, &value)
}

Expand Down Expand Up @@ -429,6 +429,17 @@ impl Value for dyn std::error::Error + 'static {
}
}

#[cfg(feature = "valuable")]
impl crate::sealed::Sealed for dyn valuable::Valuable {}

#[cfg(feature = "valuable")]
#[cfg_attr(docsrs, doc(cfg(feature = "valuable")))]
impl Value for dyn valuable::Valuable {
fn record(&self, key: &Field, visitor: &mut dyn Visit) {
visitor.record_value(key, self)
}
}

impl<'a, T: ?Sized> crate::sealed::Sealed for &'a T where T: Value + crate::sealed::Sealed + 'a {}

impl<'a, T: ?Sized> Value for &'a T
Expand Down
1 change: 1 addition & 0 deletions tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ alloc = ["tracing-core/alloc"]
std = ["tracing-core/std", "alloc"]
log-always = ["log"]
attributes = ["tracing-attributes"]
valuable = ["tracing-core/valuable"]

[[bench]]
name = "subscriber"
Expand Down

0 comments on commit 5147657

Please sign in to comment.