From 3a42c937bef2bb4fbb680b92c4a4dd32221dcfd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Thu, 3 Feb 2022 11:31:28 +0100 Subject: [PATCH] link imap debug mode with env logger (#269) --- src/domain/imap/imap_service.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/domain/imap/imap_service.rs b/src/domain/imap/imap_service.rs index 0587b51..ba38d7e 100644 --- a/src/domain/imap/imap_service.rs +++ b/src/domain/imap/imap_service.rs @@ -3,7 +3,7 @@ //! This module exposes a service that can interact with IMAP servers. use anyhow::{anyhow, Context, Result}; -use log::{debug, trace}; +use log::{debug, log_enabled, trace, Level}; use native_tls::{TlsConnector, TlsStream}; use std::{ collections::HashSet, @@ -84,12 +84,12 @@ impl<'a> ImapService<'a> { debug!("create session"); debug!("login: {}", self.account.imap_login); debug!("passwd cmd: {}", self.account.imap_passwd_cmd); - self.sess = Some( - client - .login(&self.account.imap_login, &self.account.imap_passwd()?) - .map_err(|res| res.0) - .context("cannot login to IMAP server")?, - ); + let mut sess = client + .login(&self.account.imap_login, &self.account.imap_passwd()?) + .map_err(|res| res.0) + .context("cannot login to IMAP server")?; + sess.debug = log_enabled!(Level::Trace); + self.sess = Some(sess); } match self.sess {