From 13f541469198e29f9a16f54aeecf7b55cea629c8 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 11 Feb 2020 18:39:52 +0100 Subject: cmd/koushin: add -debug flag --- session.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'session.go') diff --git a/session.go b/session.go index 3aea68e..2da29c2 100644 --- a/session.go +++ b/session.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "net/http" + "os" "sync" "time" @@ -142,17 +143,19 @@ type SessionManager struct { dialIMAP DialIMAPFunc dialSMTP DialSMTPFunc logger echo.Logger + debug bool locker sync.Mutex sessions map[string]*Session // protected by locker } -func newSessionManager(dialIMAP DialIMAPFunc, dialSMTP DialSMTPFunc, logger echo.Logger) *SessionManager { +func newSessionManager(dialIMAP DialIMAPFunc, dialSMTP DialSMTPFunc, logger echo.Logger, debug bool) *SessionManager { return &SessionManager{ sessions: make(map[string]*Session), dialIMAP: dialIMAP, dialSMTP: dialSMTP, logger: logger, + debug: debug, } } @@ -167,6 +170,10 @@ func (sm *SessionManager) connectIMAP(username, password string) (*imapclient.Cl return nil, AuthError{err} } + if sm.debug { + c.SetDebug(os.Stderr) + } + return c, nil } -- cgit v1.2.3