diff options
author | Robin Jarry <robin@jarry.cc> | 2022-11-23 10:43:44 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-02 22:10:44 +0100 |
commit | 70f46757449c8f24b818f4dfc5dcb87da7e327d6 (patch) | |
tree | a8650017ccdae1f7a4aebbdf745a0fa4ae2c2286 /worker/maildir/worker.go | |
parent | 3cd69ee953b169cf2e61b70948582df4a75cffc5 (diff) | |
download | aerc-70f46757449c8f24b818f4dfc5dcb87da7e327d6.tar.gz |
logging: homogenize levels
The main goal is to ensure that by default, the log file (if configured)
does not grow out of proportions. Most of the logging messages in aerc
are actually for debugging and/or trace purposes.
Define clear rules for logging levels. Enforce these rules everywhere.
After this patch, here is what the log file looks like after starting up
with a single account:
INFO 2022/11/24 20:26:16.147164 aerc.go:176: Starting up version 0.13.0-100-g683981479c60 (go1.18.7 amd64 linux)
INFO 2022/11/24 20:26:17.546448 account.go:254: [work] connected.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r-- | worker/maildir/worker.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index 2cf7897a..2a8a49bd 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -200,7 +200,7 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo { keyFlags[key] = flags } } else { - logging.Infof("disabled flags cache: %q: %v", dir, err) + logging.Tracef("disabled flags cache: %q: %v", dir, err) } uids, err := w.c.UIDs(dir) @@ -221,7 +221,8 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo { ok := false flags, ok = keyFlags[message.key] if !ok { - logging.Debugf("message (key=%q uid=%d) not found in map cache", message.key, message.uid) + logging.Tracef("message (key=%q uid=%d) not found in map cache", + message.key, message.uid) flags, err = message.Flags() if err != nil { logging.Errorf("could not get flags: %v", err) @@ -320,7 +321,7 @@ func (w *Worker) handleConfigure(msg *types.Configure) error { return err } w.c = c - logging.Infof("configured base maildir: %s", dir) + logging.Debugf("configured base maildir: %s", dir) return nil } @@ -357,7 +358,7 @@ func (w *Worker) handleListDirectories(msg *types.ListDirectories) error { } func (w *Worker) handleOpenDirectory(msg *types.OpenDirectory) error { - logging.Infof("opening %s", msg.Directory) + logging.Debugf("opening %s", msg.Directory) // open the directory dir, err := w.c.OpenDirectory(msg.Directory) @@ -767,13 +768,13 @@ func (w *Worker) handleAppendMessage(msg *types.AppendMessage) error { dest := w.c.Store.Dir(msg.Destination) _, writer, err := dest.Create(lib.ToMaildirFlags(msg.Flags)) if err != nil { - logging.Errorf("could not create message at %s: %v", msg.Destination, err) - return err + return fmt.Errorf("could not create message at %s: %w", + msg.Destination, err) } defer writer.Close() if _, err := io.Copy(writer, msg.Reader); err != nil { - logging.Errorf("could not write message to destination: %v", err) - return err + return fmt.Errorf( + "could not write message to destination: %w", err) } w.worker.PostMessage(&types.Done{ Message: types.RespondTo(msg), @@ -785,12 +786,12 @@ func (w *Worker) handleAppendMessage(msg *types.AppendMessage) error { } func (w *Worker) handleSearchDirectory(msg *types.SearchDirectory) error { - logging.Infof("Searching directory %v with args: %v", *w.selected, msg.Argv) + logging.Debugf("Searching directory %v with args: %v", *w.selected, msg.Argv) criteria, err := parseSearch(msg.Argv) if err != nil { return err } - logging.Infof("Searching with parsed criteria: %#v", criteria) + logging.Tracef("Searching with parsed criteria: %#v", criteria) uids, err := w.search(criteria) if err != nil { return err |