pub trait TracingValuableExt {
type Redacted: Valuable;
// Required method
fn tracing_redacted_valuable(&self) -> RedactedValuable<Self::Redacted>;
}Expand description
Extension trait for logging redacted values as structured valuable data.
This requires the tracing-valuable feature, RUSTFLAGS="--cfg tracing_unstable", and a tracing subscriber that supports the valuable
crate. The returned wrapper is not itself a tracing::Value; bind it first,
then pass a reference through tracing::field::valuable.
§Example
tracing::field::valuable is hidden by upstream tracing unless the crate
is compiled with RUSTFLAGS="--cfg tracing_unstable", so this example cannot
be compiled by ordinary doctest runs.
use redactable::{Secret, Sensitive};
use redactable::tracing::TracingValuableExt;
#[derive(Clone, Sensitive, valuable::Valuable)]
struct User {
username: String,
#[sensitive(Secret)]
password: String,
}
let user = User { username: "alice".into(), password: "secret".into() };
let redacted = user.tracing_redacted_valuable();
tracing::info!(user = tracing::field::valuable(&redacted));Required Associated Types§
Required Methods§
Sourcefn tracing_redacted_valuable(&self) -> RedactedValuable<Self::Redacted>
fn tracing_redacted_valuable(&self) -> RedactedValuable<Self::Redacted>
Redacts the value and wraps it for structured tracing output.
The returned RedactedValuable implements valuable::Valuable, allowing
tracing subscribers to inspect the redacted structure when passed through
tracing::field::valuable(&binding) under tracing_unstable.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<T> TracingValuableExt for T
Available on crate feature tracing-valuable only.
impl<T> TracingValuableExt for T
tracing-valuable only.