aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

commit 1767e4fab515cefba08345e6eb2c84f46daf4be1
parent d24e4712a45e03d79fa1ccb71d00c5b830d5a305
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu,  1 Feb 2018 18:59:13 -0500

Improve logging

Diffstat:
Mcmd/aerc/main.go | 6++----
Mworker/types/worker.go | 26++++++++++++++++++++------
2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/cmd/aerc/main.go b/cmd/aerc/main.go @@ -22,7 +22,7 @@ func main() { } else { logOut = ioutil.Discard } - logger = log.New(logOut, "", log.LstdFlags|log.Lshortfile) + logger = log.New(logOut, "", log.LstdFlags) logger.Println("Starting up aerc") conf, err := config.LoadConfig(nil) @@ -37,9 +37,7 @@ func main() { for _, account := range conf.Accounts { logger.Printf("Initializing account %s\n", account.Name) tab, err := ui.NewAccountTab(&account, log.New( - logOut, - fmt.Sprintf("[%s] ", account.Name), - log.LstdFlags|log.Lshortfile)) + logOut, fmt.Sprintf("[%s] ", account.Name), log.LstdFlags)) if err != nil { panic(err) } diff --git a/worker/types/worker.go b/worker/types/worker.go @@ -19,7 +19,11 @@ type Worker struct { func (worker *Worker) PostAction(msg WorkerMessage, cb func(msg WorkerMessage)) { - worker.Logger.Printf("=> %T\n", msg) + if resp := msg.InResponseTo(); resp != nil { + worker.Logger.Printf("(ui)=> %T:%T\n", msg, resp) + } else { + worker.Logger.Printf("(ui)=> %T\n", msg) + } worker.Actions <- msg if cb != nil { @@ -30,7 +34,11 @@ func (worker *Worker) PostAction(msg WorkerMessage, func (worker *Worker) PostMessage(msg WorkerMessage, cb func(msg WorkerMessage)) { - worker.Logger.Printf("-> %T\n", msg) + if resp := msg.InResponseTo(); resp != nil { + worker.Logger.Printf("->(ui) %T:%T\n", msg, resp) + } else { + worker.Logger.Printf("->(ui) %T\n", msg) + } worker.Messages <- msg if cb != nil { @@ -39,8 +47,11 @@ func (worker *Worker) PostMessage(msg WorkerMessage, } func (worker *Worker) ProcessMessage(msg WorkerMessage) WorkerMessage { - - worker.Logger.Printf("<= %T\n", msg) + if resp := msg.InResponseTo(); resp != nil { + worker.Logger.Printf("(ui)<= %T:%T\n", msg, resp) + } else { + worker.Logger.Printf("(ui)<= %T\n", msg) + } if cb, ok := worker.Callbacks[msg.InResponseTo()]; ok { cb(msg) delete(worker.Callbacks, msg) @@ -49,8 +60,11 @@ func (worker *Worker) ProcessMessage(msg WorkerMessage) WorkerMessage { } func (worker *Worker) ProcessAction(msg WorkerMessage) WorkerMessage { - - worker.Logger.Printf("<- %T\n", msg) + if resp := msg.InResponseTo(); resp != nil { + worker.Logger.Printf("<-(ui) %T:%T\n", msg, resp) + } else { + worker.Logger.Printf("<-(ui) %T\n", msg) + } if cb, ok := worker.Callbacks[msg.InResponseTo()]; ok { cb(msg) delete(worker.Callbacks, msg)