link imap debug mode with env logger (#269)

This commit is contained in:
Clément DOUIN 2022-02-03 11:31:28 +01:00
parent 8cdeba62a1
commit 3a42c937be
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72

View file

@ -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 {