diff --git a/.gitignore b/.gitignore index 1abf5ef3b..9288036de 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 670852964..65314237c 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) {