From 080b8ae77562eb917f083fb923f3b8f1a43155cf Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 15 Sep 2019 23:44:42 +0300 Subject: [PATCH] imap: add log entry on connection retry & failure --- melib/src/backends/imap/connection.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/melib/src/backends/imap/connection.rs b/melib/src/backends/imap/connection.rs index a5c7a0ec..6497afc0 100644 --- a/melib/src/backends/imap/connection.rs +++ b/melib/src/backends/imap/connection.rs @@ -21,6 +21,7 @@ use crate::email::parser::BytesExt; use crate::error::*; +use crate::logging::{LoggingLevel::*, *}; use std::io::Read; use std::io::Write; extern crate native_tls; @@ -98,6 +99,13 @@ impl ImapConnection { std::mem::replace(&mut self.server_username, String::new()); let server_password = std::mem::replace(&mut self.server_password, String::new()); + log( + format!( + "IMAP connection to `{}` failed. Retrying one more time...", + &server_hostname + ), + ERROR, + ); *self = ImapConnection::new_connection( server_hostname, server_username, @@ -107,7 +115,13 @@ impl ImapConnection { .1; connection_tries += 1; } - Err(e) => return Err(MeliError::from(e)), + Err(e) => { + log( + format!("IMAP connection to `{}` failed.", &self.server_hostname), + FATAL, + ); + return Err(MeliError::from(e)); + } } } Ok(())