diff options
author | Robin Jarry <robin@jarry.cc> | 2022-07-19 22:31:51 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-23 22:52:15 +0200 |
commit | cd1999555714fb886493d2d04b6c472be55cebef (patch) | |
tree | 1df3bcf5f687752db671d8bc9c7eab8a5c0fde71 /worker/imap/worker.go | |
parent | a1f779ccc9b16b22ad6cb2e0bf73c290fd0cc756 (diff) | |
download | aerc-cd1999555714fb886493d2d04b6c472be55cebef.zip |
logging: use level-based logger functions
Do not pass logger objects around anymore. Shuffle some messages to make
them consistent with the new logging API. Avoid using %v when a more
specific verb exists for the argument types.
The loggers are completely disabled (i.e. Sprintf is not even called)
by default. They are only enabled when redirecting stdout to a file.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'worker/imap/worker.go')
-rw-r--r-- | worker/imap/worker.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/worker/imap/worker.go b/worker/imap/worker.go index 3ed646d..dee089e 100644 --- a/worker/imap/worker.go +++ b/worker/imap/worker.go @@ -12,6 +12,7 @@ import ( "github.com/syndtr/goleveldb/leveldb" "git.sr.ht/~rjarry/aerc/lib" + "git.sr.ht/~rjarry/aerc/logging" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/handlers" "git.sr.ht/~rjarry/aerc/worker/types" @@ -89,12 +90,12 @@ func (w *IMAPWorker) newClient(c *client.Client) { sort, err := w.client.sort.SupportSort() if err == nil && sort { w.caps.Sort = true - w.worker.Logger.Println("Server Capability found: Sort") + logging.Infof("Server Capability found: Sort") } thread, err := w.client.thread.SupportThread() if err == nil && thread { w.caps.Thread = true - w.worker.Logger.Println("Server Capability found: Thread") + logging.Infof("Server Capability found: Thread") } } @@ -223,7 +224,7 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { } func (w *IMAPWorker) handleImapUpdate(update client.Update) { - w.worker.Logger.Printf("(= %T", update) + logging.Debugf("(= %T", update) switch update := update.(type) { case *client.MailboxUpdate: status := update.Mailbox @@ -246,7 +247,7 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) { msg := update.Message if msg.Uid == 0 { if uid, found := w.seqMap.Get(msg.SeqNum); !found { - w.worker.Logger.Printf("MessageUpdate unknown seqnum: %v", msg.SeqNum) + logging.Errorf("MessageUpdate unknown seqnum: %d", msg.SeqNum) return } else { msg.Uid = uid @@ -263,7 +264,7 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) { }, nil) case *client.ExpungeUpdate: if uid, found := w.seqMap.Pop(update.SeqNum); !found { - w.worker.Logger.Printf("ExpungeUpdate unknown seqnum: %v", update.SeqNum) + logging.Errorf("ExpungeUpdate unknown seqnum: %d", update.SeqNum) } else { w.worker.PostMessage(&types.MessagesDeleted{ Uids: []uint32{uid}, |