aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/open.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-07-19 22:31:51 +0200
committerRobin Jarry <robin@jarry.cc>2022-07-23 22:52:15 +0200
commitcd1999555714fb886493d2d04b6c472be55cebef (patch)
tree1df3bcf5f687752db671d8bc9c7eab8a5c0fde71 /worker/imap/open.go
parenta1f779ccc9b16b22ad6cb2e0bf73c290fd0cc756 (diff)
downloadaerc-cd1999555714fb886493d2d04b6c472be55cebef.tar.gz
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/open.go')
-rw-r--r--worker/imap/open.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/worker/imap/open.go b/worker/imap/open.go
index b52a3c65..636b936c 100644
--- a/worker/imap/open.go
+++ b/worker/imap/open.go
@@ -5,11 +5,12 @@ import (
sortthread "github.com/emersion/go-imap-sortthread"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/worker/types"
)
func (imapw *IMAPWorker) handleOpenDirectory(msg *types.OpenDirectory) {
- imapw.worker.Logger.Printf("Opening %s", msg.Directory)
+ logging.Infof("Opening %s", msg.Directory)
sel, err := imapw.client.Select(msg.Directory, false)
if err != nil {
@@ -26,7 +27,7 @@ func (imapw *IMAPWorker) handleOpenDirectory(msg *types.OpenDirectory) {
func (imapw *IMAPWorker) handleFetchDirectoryContents(
msg *types.FetchDirectoryContents) {
- imapw.worker.Logger.Printf("Fetching UID list")
+ logging.Infof("Fetching UID list")
searchCriteria, err := parseSearch(msg.FilterCriteria)
if err != nil {
@@ -51,7 +52,7 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents(
} else {
if err != nil {
// Non fatal, but we do want to print to get some debug info
- imapw.worker.Logger.Printf("can't check for SORT support: %v", err)
+ logging.Errorf("can't check for SORT support: %v", err)
}
uids, err = imapw.client.UidSearch(searchCriteria)
}
@@ -61,7 +62,7 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents(
Error: err,
}, nil)
} else {
- imapw.worker.Logger.Printf("Found %d UIDs", len(uids))
+ logging.Infof("Found %d UIDs", len(uids))
imapw.seqMap.Clear()
imapw.worker.PostMessage(&types.DirectoryContents{
Message: types.RespondTo(msg),
@@ -97,7 +98,7 @@ func translateSortCriterions(
func (imapw *IMAPWorker) handleDirectoryThreaded(
msg *types.FetchDirectoryThreaded) {
- imapw.worker.Logger.Printf("Fetching threaded UID list")
+ logging.Infof("Fetching threaded UID list")
searchCriteria, err := parseSearch(msg.FilterCriteria)
if err != nil {
@@ -117,7 +118,7 @@ func (imapw *IMAPWorker) handleDirectoryThreaded(
} else {
aercThreads, count := convertThreads(threads, nil)
sort.Sort(types.ByUID(aercThreads))
- imapw.worker.Logger.Printf("Found %d threaded messages", count)
+ logging.Infof("Found %d threaded messages", count)
imapw.seqMap.Clear()
imapw.worker.PostMessage(&types.DirectoryThreaded{
Message: types.RespondTo(msg),