From 536cceca78c9cc1798b3c20d0d3b84a52025ce56 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Tue, 17 May 2022 21:37:05 +0200 Subject: [PATCH] lock only ones --- src/utils/logging.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/logging.rs b/src/utils/logging.rs index b8fa2339..af72aa22 100644 --- a/src/utils/logging.rs +++ b/src/utils/logging.rs @@ -103,11 +103,12 @@ impl Log for LogMailer { let time_stamp = local.format("[%Y-%m-%d %H:%M:%S%.3f]"); let level = record.level().to_string().to_uppercase(); let rec = record.args().to_string(); + let mut last_msg = self.last_message.lock().unwrap(); // put message only to mail queue when it differs from last message // this we do to prevent spamming the mail box - if *self.last_message.lock().unwrap() != rec { - *self.last_message.lock().unwrap() = rec.clone(); + if *last_msg != rec { + *last_msg = rec.clone(); let full_line: String = format!("{time_stamp} [{level: >5}] {rec}"); self.messages.lock().unwrap().push(full_line);