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 /lib | |
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 'lib')
-rw-r--r-- | lib/attachment.go | 2 | ||||
-rw-r--r-- | lib/crypto/gpg/gpgbin/gpgbin.go | 2 | ||||
-rw-r--r-- | lib/crypto/pgp/pgp.go | 2 | ||||
-rw-r--r-- | lib/msgstore.go | 2 | ||||
-rw-r--r-- | lib/open.go | 2 | ||||
-rw-r--r-- | lib/socket.go | 16 | ||||
-rw-r--r-- | lib/threadbuilder.go | 2 |
7 files changed, 16 insertions, 12 deletions
diff --git a/lib/attachment.go b/lib/attachment.go index bc29a567..e926dfa9 100644 --- a/lib/attachment.go +++ b/lib/attachment.go @@ -153,7 +153,7 @@ func SetUtf8Charset(origParams map[string]string) map[string]string { for k, v := range origParams { switch strings.ToLower(k) { case "charset": - logging.Infof("substitute charset %s with utf-8", v) + logging.Debugf("substitute charset %s with utf-8", v) params[k] = "utf-8" default: params[k] = v diff --git a/lib/crypto/gpg/gpgbin/gpgbin.go b/lib/crypto/gpg/gpgbin/gpgbin.go index 1e8c7dcd..d83c45fb 100644 --- a/lib/crypto/gpg/gpgbin/gpgbin.go +++ b/lib/crypto/gpg/gpgbin/gpgbin.go @@ -129,7 +129,7 @@ func parse(r io.Reader, md *models.MessageDetails) error { } if strings.HasPrefix(line, "[GNUPG:]") { msgCollecting = false - logging.Debugf(line) + logging.Tracef(line) } if msgCollecting { msgContent = append(msgContent, scanner.Bytes()...) diff --git a/lib/crypto/pgp/pgp.go b/lib/crypto/pgp/pgp.go index f5612eea..fd9d13eb 100644 --- a/lib/crypto/pgp/pgp.go +++ b/lib/crypto/pgp/pgp.go @@ -29,7 +29,7 @@ var ( ) func (m *Mail) Init() error { - logging.Infof("Initializing PGP keyring") + logging.Debugf("Initializing PGP keyring") err := os.MkdirAll(path.Join(xdg.DataHome(), "aerc"), 0o700) if err != nil { return fmt.Errorf("failed to create data directory: %w", err) diff --git a/lib/msgstore.go b/lib/msgstore.go index dfa25191..4205ea10 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -420,7 +420,7 @@ func (store *MessageStore) runThreadBuilder() { } if store.threadBuilderDebounce != nil { if store.threadBuilderDebounce.Stop() { - logging.Infof("thread builder debounced") + logging.Tracef("thread builder debounced") } } store.threadBuilderDebounce = time.AfterFunc(store.threadBuilderDelay, func() { diff --git a/lib/open.go b/lib/open.go index e091d913..9faa6d10 100644 --- a/lib/open.go +++ b/lib/open.go @@ -46,7 +46,7 @@ func XDGOpenMime( args = append(args, uri) } - logging.Infof("running command: %v", args) + logging.Tracef("running command: %v", args) cmd := exec.Command(args[0], args[1:]...) out, err := cmd.CombinedOutput() logging.Debugf("command: %v exited. err=%v out=%s", args, err, out) diff --git a/lib/socket.go b/lib/socket.go index 4da3485b..1cfd0583 100644 --- a/lib/socket.go +++ b/lib/socket.go @@ -28,7 +28,7 @@ func StartServer() (*AercServer, error) { if err := ConnectAndExec(""); err != nil { os.Remove(sockpath) } - logging.Infof("Starting Unix server: %s", sockpath) + logging.Debugf("Starting Unix server: %s", sockpath) l, err := net.Listen("unix", sockpath) if err != nil { return nil, err @@ -41,9 +41,13 @@ func StartServer() (*AercServer, error) { for { conn, err := l.Accept() if err != nil { - // TODO: Something more useful, in some cases, on wednesdays, - // after 2 PM, I guess? - logging.Errorf("Closing Unix server: %v", err) + if !strings.Contains(err.Error(), + "use of closed network connection") { + // TODO: Something more useful, in some + // cases, on wednesdays, after 2 PM, + // I guess? + logging.Errorf("Closing Unix server: %v", err) + } return } go func() { @@ -76,7 +80,7 @@ func (as *AercServer) handleClient(conn net.Conn) { logging.Errorf("failed to update deadline: %v", err) } msg := scanner.Text() - logging.Debugf("unix:%d got message %s", clientId, msg) + logging.Tracef("unix:%d got message %s", clientId, msg) if !strings.ContainsRune(msg, ':') { _, innererr := conn.Write([]byte("error: invalid command\n")) if innererr != nil { @@ -119,7 +123,7 @@ func (as *AercServer) handleClient(conn net.Conn) { } } } - logging.Debugf("unix:%d closed connection", clientId) + logging.Tracef("unix:%d closed connection", clientId) } func ConnectAndExec(msg string) error { diff --git a/lib/threadbuilder.go b/lib/threadbuilder.go index 600f6539..34f143a4 100644 --- a/lib/threadbuilder.go +++ b/lib/threadbuilder.go @@ -67,7 +67,7 @@ func (builder *ThreadBuilder) Threads(uids []uint32, inverse bool, sort bool, builder.RebuildUids(threads, inverse) elapsed := time.Since(start) - logging.Infof("%d threads from %d uids created in %s", len(threads), + logging.Tracef("%d threads from %d uids created in %s", len(threads), len(uids), elapsed) return threads |