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

Sifting plugin private fields on debug logs. #592

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions commons/zenoh-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,15 @@ impl Config {

impl std::fmt::Display for Config {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut json = serde_json::to_value(self).unwrap();
sift_privates(&mut json);
write!(f, "{json}")
serde_json::to_value(self)
.map(|mut json| {
sift_privates(&mut json);
write!(f, "{json}")
})
.map_err(|e| {
_ = write!(f, "{e:?}");
fmt::Error
})?
}
}

Expand Down Expand Up @@ -1030,9 +1036,12 @@ impl<'a> serde::Deserialize<'a> for PluginsConfig {
})
}
}

impl std::fmt::Debug for PluginsConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", &self.values)
let mut values: Value = self.values.clone();
sift_privates(&mut values);
write!(f, "{:?}", values)
}
}

Expand Down
Loading