summary refs log tree commit diff stats
path: root/ui/account.go
diff options
context:
space:
mode:
Diffstat (limited to 'ui/account.go')
-rw-r--r--ui/account.go31
1 files changed, 19 insertions, 12 deletions
diff --git a/ui/account.go b/ui/account.go
index 8353db3..59544d4 100644
--- a/ui/account.go
+++ b/ui/account.go
@@ -1,26 +1,29 @@
 package ui
 
 import (
-	"fmt"
+	"log"
 
 	tb "github.com/nsf/termbox-go"
 
+	"github.com/davecgh/go-spew/spew"
+
 	"git.sr.ht/~sircmpwn/aerc2/config"
 	"git.sr.ht/~sircmpwn/aerc2/worker"
 	"git.sr.ht/~sircmpwn/aerc2/worker/types"
 )
 
 type AccountTab struct {
-	Config *config.AccountConfig
-	Worker worker.Worker
-	Parent *UIState
-
+	Config  *config.AccountConfig
+	Worker  worker.Worker
+	Parent  *UIState
+	logger  *log.Logger
 	counter int
-	log     []string
 }
 
-func NewAccountTab(conf *config.AccountConfig) (*AccountTab, error) {
-	work, err := worker.NewWorker(conf.Source)
+func NewAccountTab(conf *config.AccountConfig,
+	logger *log.Logger) (*AccountTab, error) {
+
+	work, err := worker.NewWorker(conf.Source, logger)
 	if err != nil {
 		return nil, err
 	}
@@ -30,6 +33,7 @@ func NewAccountTab(conf *config.AccountConfig) (*AccountTab, error) {
 	return &AccountTab{
 		Config: conf,
 		Worker: work,
+		logger: logger,
 	}, nil
 }
 
@@ -49,9 +53,6 @@ func (acc *AccountTab) Render(at Geometry) {
 	}
 	TFill(at, cell)
 	TPrintf(&at, cell, "%s %d\n", acc.Name(), acc.counter)
-	for _, str := range acc.log {
-		TPrintf(&at, cell, "%s\n", str)
-	}
 	acc.counter++
 	if acc.counter%10000 == 0 {
 		acc.counter = 0
@@ -64,5 +65,11 @@ func (acc *AccountTab) GetChannel() chan types.WorkerMessage {
 }
 
 func (acc *AccountTab) HandleMessage(msg types.WorkerMessage) {
-	acc.log = append(acc.log, fmt.Sprintf("<- %T", msg))
+	switch msg.InResponseTo().(type) {
+	case types.Configure:
+		// Avoid printing passwords
+		acc.logger.Printf("<- %T\n", msg)
+	default:
+		acc.logger.Printf("<- %s", spew.Sdump(msg))
+	}
 }
a id='n192' href='#n192'>192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235