aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-11-23 10:43:44 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-02 22:10:44 +0100
commit70f46757449c8f24b818f4dfc5dcb87da7e327d6 (patch)
treea8650017ccdae1f7a4aebbdf745a0fa4ae2c2286 /commands
parent3cd69ee953b169cf2e61b70948582df4a75cffc5 (diff)
downloadaerc-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 'commands')
-rw-r--r--commands/account/export-mbox.go2
-rw-r--r--commands/account/import-mbox.go4
-rw-r--r--commands/account/search.go4
-rw-r--r--commands/compose/attach.go11
-rw-r--r--commands/compose/postpone.go2
-rw-r--r--commands/msg/forward.go2
-rw-r--r--commands/msg/recall.go4
-rw-r--r--commands/msg/unsubscribe.go4
8 files changed, 15 insertions, 18 deletions
diff --git a/commands/account/export-mbox.go b/commands/account/export-mbox.go
index b68e1cc5..f51608b9 100644
--- a/commands/account/export-mbox.go
+++ b/commands/account/export-mbox.go
@@ -117,7 +117,7 @@ func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error {
}
statusInfo := fmt.Sprintf("Exported %d of %d messages to %s.", ctr, len(store.Uids()), filename)
aerc.PushStatus(statusInfo, 10*time.Second)
- logging.Infof(statusInfo)
+ logging.Debugf(statusInfo)
}()
return nil
diff --git a/commands/account/import-mbox.go b/commands/account/import-mbox.go
index 5a8a2ee6..93408aca 100644
--- a/commands/account/import-mbox.go
+++ b/commands/account/import-mbox.go
@@ -55,7 +55,7 @@ func (ImportMbox) Execute(aerc *widgets.Aerc, args []string) error {
importFolder := func() {
statusInfo := fmt.Sprintln("Importing", filename, "to folder", folder)
aerc.PushStatus(statusInfo, 10*time.Second)
- logging.Infof(statusInfo)
+ logging.Debugf(statusInfo)
f, err := os.Open(filename)
if err != nil {
aerc.PushError(err.Error())
@@ -123,7 +123,7 @@ func (ImportMbox) Execute(aerc *widgets.Aerc, args []string) error {
}
}
infoStr := fmt.Sprintf("%s: imported %d of %d sucessfully.", args[0], appended, len(messages))
- logging.Infof(infoStr)
+ logging.Debugf(infoStr)
aerc.SetStatus(infoStr)
}
diff --git a/commands/account/search.go b/commands/account/search.go
index b4942bf5..125cb5d7 100644
--- a/commands/account/search.go
+++ b/commands/account/search.go
@@ -44,7 +44,7 @@ func (SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
cb := func(msg types.WorkerMessage) {
if _, ok := msg.(*types.Done); ok {
acct.SetStatus(statusline.FilterResult(strings.Join(args, " ")))
- logging.Infof("Filter results: %v", store.Uids())
+ logging.Tracef("Filter results: %v", store.Uids())
}
}
store.Sort(store.GetCurrentSortCriteria(), cb)
@@ -52,7 +52,7 @@ func (SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
acct.SetStatus(statusline.Search("Searching..."))
cb := func(uids []uint32) {
acct.SetStatus(statusline.Search(strings.Join(args, " ")))
- logging.Infof("Search results: %v", uids)
+ logging.Tracef("Search results: %v", uids)
store.ApplySearch(uids)
// TODO: Remove when stores have multiple OnUpdate handlers
ui.Invalidate()
diff --git a/commands/compose/attach.go b/commands/compose/attach.go
index af5c023c..de83ef0b 100644
--- a/commands/compose/attach.go
+++ b/commands/compose/attach.go
@@ -52,16 +52,12 @@ func (a Attach) addPath(aerc *widgets.Aerc, path string) error {
return err
}
- logging.Debugf("attaching %s", path)
-
attachments, err := filepath.Glob(path)
if err != nil && errors.Is(err, filepath.ErrBadPattern) {
logging.Warnf("failed to parse as globbing pattern: %v", err)
attachments = []string{path}
}
- logging.Debugf("filenames: %v", attachments)
-
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
for _, attach := range attachments {
logging.Debugf("attaching '%s'", attach)
@@ -134,6 +130,7 @@ func (a Attach) openMenu(aerc *widgets.Aerc, args []string) error {
_, err = picks.Seek(0, io.SeekStart)
if err != nil {
logging.Errorf("seek failed: %v", err)
+ return
}
scanner := bufio.NewScanner(picks)
@@ -142,11 +139,11 @@ func (a Attach) openMenu(aerc *widgets.Aerc, args []string) error {
if _, err := os.Stat(f); err != nil {
continue
}
- logging.Infof("File picker attaches: %v", f)
+ logging.Tracef("File picker attaches: %v", f)
err := a.addPath(aerc, f)
if err != nil {
- logging.Errorf("attach failed "+
- "for file %s: %v", f, err)
+ logging.Errorf(
+ "attach failed for file %s: %v", f, err)
}
}
diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go
index 7469b235..2572d8d5 100644
--- a/commands/compose/postpone.go
+++ b/commands/compose/postpone.go
@@ -47,7 +47,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("No Postpone location configured")
}
- logging.Infof("Postponing mail")
+ logging.Tracef("Postponing mail")
header, err := composer.PrepareHeader()
if err != nil {
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index ccfaa086..74ee6575 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -74,7 +74,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return err
}
- logging.Infof("Forwarding email %s", msg.Envelope.MessageId)
+ logging.Debugf("Forwarding email <%s>", msg.Envelope.MessageId)
h := &mail.Header{}
subject := "Fwd: " + msg.Envelope.Subject
diff --git a/commands/msg/recall.go b/commands/msg/recall.go
index b5c92f21..eb8195f8 100644
--- a/commands/msg/recall.go
+++ b/commands/msg/recall.go
@@ -70,7 +70,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return errors.Wrap(err, "Recall failed")
}
- logging.Infof("Recalling message %s", msgInfo.Envelope.MessageId)
+ logging.Debugf("Recalling message <%s>", msgInfo.Envelope.MessageId)
composer, err := widgets.NewComposer(aerc, acct, aerc.Config(),
acct.AccountConfig(), acct.Worker(), "", msgInfo.RFC822Headers,
@@ -200,7 +200,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
}
bs, err := msg.BodyStructure().PartAtIndex(p)
if err != nil {
- logging.Infof("cannot get PartAtIndex %v: %v", p, err)
+ logging.Warnf("cannot get PartAtIndex %v: %v", p, err)
continue
}
msg.FetchBodyPart(p, func(reader io.Reader) {
diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go
index 022135eb..72c839fe 100644
--- a/commands/msg/unsubscribe.go
+++ b/commands/msg/unsubscribe.go
@@ -56,10 +56,10 @@ func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error {
if len(methods) == 0 {
return fmt.Errorf("no methods found to unsubscribe")
}
- logging.Infof("unsubscribe: found %d methods", len(methods))
+ logging.Debugf("unsubscribe: found %d methods", len(methods))
unsubscribe := func(method *url.URL) {
- logging.Infof("unsubscribe: trying to unsubscribe using %s", method.Scheme)
+ logging.Debugf("unsubscribe: trying to unsubscribe using %s", method.Scheme)
var err error
switch strings.ToLower(method.Scheme) {
case "mailto":