lock only ones

This commit is contained in:
jb-alvarado 2022-05-17 21:37:05 +02:00
parent fb85b84e61
commit 536cceca78

View File

@ -103,11 +103,12 @@ impl Log for LogMailer {
let time_stamp = local.format("[%Y-%m-%d %H:%M:%S%.3f]"); let time_stamp = local.format("[%Y-%m-%d %H:%M:%S%.3f]");
let level = record.level().to_string().to_uppercase(); let level = record.level().to_string().to_uppercase();
let rec = record.args().to_string(); 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 // put message only to mail queue when it differs from last message
// this we do to prevent spamming the mail box // this we do to prevent spamming the mail box
if *self.last_message.lock().unwrap() != rec { if *last_msg != rec {
*self.last_message.lock().unwrap() = rec.clone(); *last_msg = rec.clone();
let full_line: String = format!("{time_stamp} [{level: >5}] {rec}"); let full_line: String = format!("{time_stamp} [{level: >5}] {rec}");
self.messages.lock().unwrap().push(full_line); self.messages.lock().unwrap().push(full_line);