Skip to content

Commit

Permalink
Sifting plugin private fields on debug logs. (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIMP authored Nov 27, 2023
1 parent 8ebf8b8 commit bbd12e2
Showing 1 changed file with 13 additions and 4 deletions.
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

0 comments on commit bbd12e2

Please sign in to comment.