diff --git a/.gitignore b/.gitignore index 1abf5ef3b4..9288036de0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ **/*.rej **/target **/.vscode +pkg/logging/Cargo.lock src/agent/src/version.rs src/agent/kata-agent.service diff --git a/pkg/logging/src/lib.rs b/pkg/logging/src/lib.rs index 6708529643..65314237cf 100644 --- a/pkg/logging/src/lib.rs +++ b/pkg/logging/src/lib.rs @@ -93,9 +93,7 @@ impl HashSerializer { // Take care to only add the first instance of a key. This matters for loggers (but not // Records) since a child loggers have parents and the loggers are serialised child first // meaning the *newest* fields are serialised first. - if !self.fields.contains_key(&key) { - self.fields.insert(key, value); - } + self.fields.entry(key).or_insert(value); } fn remove_field(&mut self, key: &str) {