Skip to content

Commit

Permalink
add logging and debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
da-coda committed Jan 19, 2021
1 parent eaf091c commit 57f0435
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mailpie.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type errorState struct {
}

func main() {
logrus.SetLevel(logrus.DebugLevel)
errorChannel := make(chan errorState)
go serveSPA(errorChannel)
go serveSSE(errorChannel)
Expand Down Expand Up @@ -72,7 +73,10 @@ func serveSMTP(errorChannel chan errorState) {
AuthHandler: func(remoteAddr net.Addr, mechanism string, username []byte, password []byte, shared []byte) (bool, error) {
return true, nil
},
AuthMechs: map[string]bool{"PLAIN": true, "LOGIN": true},
LogWrite: func(remoteIP, verb, line string) {
logrus.WithField("ip", remoteIP).WithField("verb", verb).Debug(line)
},
AuthMechs: map[string]bool{"PLAIN": true, "LOGIN": true, "CRAM-MD5": false},
}
logrus.WithField("Address", addr).Info("Starting SMTP server")
err := srv.ListenAndServe()
Expand Down Expand Up @@ -144,7 +148,8 @@ func serveSSE(errorChannel chan errorState) {
func serveIMAP(errorChannel chan errorState) {
be := imap.NewBackend()
s := server.New(be)
s.Debug = os.Stdout
imapLogger := logrus.New()
s.Debug = imapLogger.Writer()
s.Addr = listenOnAddress + ":1143"
s.AllowInsecureAuth = true
logrus.WithField("Address", s.Addr).Info("Starting IMAP server")
Expand Down
3 changes: 3 additions & 0 deletions pkg/event/events.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package event

import "github.com/sirupsen/logrus"

type Handler func(dispatcher string, data interface{})

type MessageQueue struct {
Expand All @@ -18,6 +20,7 @@ func NewOrGet() *MessageQueue {
}

func (mq MessageQueue) Dispatch(event string, from string, data interface{}) {
logrus.WithFields(map[string]interface{}{"event": event, "from": from}).Debug("New Event Dispatched")
subscriber, ok := mq.topics[event]
if !ok {
return
Expand Down

0 comments on commit 57f0435

Please sign in to comment.