aboutsummaryrefslogtreecommitdiff
path: root/session.go
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-02-11 18:39:52 +0100
committerSimon Ser <contact@emersion.fr>2020-02-11 18:39:52 +0100
commit13f541469198e29f9a16f54aeecf7b55cea629c8 (patch)
tree37e2e0af377f63545725acca8cddd0acfc05bf66 /session.go
parente59ad57e32289ef62e17a8361b6d36b77e56a25d (diff)
downloadalps-13f541469198e29f9a16f54aeecf7b55cea629c8.tar.gz
alps-13f541469198e29f9a16f54aeecf7b55cea629c8.zip
cmd/koushin: add -debug flag
Diffstat (limited to 'session.go')
-rw-r--r--session.go9
1 files changed, 8 insertions, 1 deletions
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
}