diff options
author | Robin Jarry <robin@jarry.cc> | 2022-11-27 11:29:34 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-02 22:10:49 +0100 |
commit | 23a05d17ac1d23466ff73efa19576d43d06efe4b (patch) | |
tree | 49986587a62bdd89eb06ffa2aadf05f6d45cb3e7 /lib | |
parent | 70f46757449c8f24b818f4dfc5dcb87da7e327d6 (diff) | |
download | aerc-23a05d17ac1d23466ff73efa19576d43d06efe4b.tar.gz |
logging: rename package to log
Use the same name than the builtin "log" package. That way, we do not
risk logging in the wrong place.
Suggested-by: Tim Culverhouse <tim@timculverhouse.com>
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 | 4 | ||||
-rw-r--r-- | lib/crypto/gpg/gpgbin/gpgbin.go | 8 | ||||
-rw-r--r-- | lib/crypto/pgp/pgp.go | 4 | ||||
-rw-r--r-- | lib/messageview.go | 6 | ||||
-rw-r--r-- | lib/msgstore.go | 6 | ||||
-rw-r--r-- | lib/open.go | 6 | ||||
-rw-r--r-- | lib/parse/ansi.go | 6 | ||||
-rw-r--r-- | lib/socket.go | 30 | ||||
-rw-r--r-- | lib/threadbuilder.go | 6 | ||||
-rw-r--r-- | lib/ui/textinput.go | 4 |
10 files changed, 40 insertions, 40 deletions
diff --git a/lib/attachment.go b/lib/attachment.go index e926dfa9..5c2284f5 100644 --- a/lib/attachment.go +++ b/lib/attachment.go @@ -10,7 +10,7 @@ import ( "path/filepath" "strings" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" "github.com/emersion/go-message/mail" "github.com/pkg/errors" ) @@ -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.Debugf("substitute charset %s with utf-8", v) + log.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 d83c45fb..a83ebb37 100644 --- a/lib/crypto/gpg/gpgbin/gpgbin.go +++ b/lib/crypto/gpg/gpgbin/gpgbin.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" ) @@ -65,7 +65,7 @@ func getIdentity(key uint64) string { cmd.Stdout = &outbuf err := cmd.Run() if err != nil { - logging.Errorf("gpg: failed to get identity: %v", err) + log.Errorf("gpg: failed to get identity: %v", err) return "" } out := strings.Split(outbuf.String(), "\n") @@ -91,7 +91,7 @@ func getKeyId(s string, private bool) string { cmd.Stdout = &outbuf err := cmd.Run() if err != nil { - logging.Errorf("gpg: failed to get key ID: %v", err) + log.Errorf("gpg: failed to get key ID: %v", err) return "" } out := strings.Split(outbuf.String(), "\n") @@ -129,7 +129,7 @@ func parse(r io.Reader, md *models.MessageDetails) error { } if strings.HasPrefix(line, "[GNUPG:]") { msgCollecting = false - logging.Tracef(line) + log.Tracef(line) } if msgCollecting { msgContent = append(msgContent, scanner.Bytes()...) diff --git a/lib/crypto/pgp/pgp.go b/lib/crypto/pgp/pgp.go index fd9d13eb..b2f5fa24 100644 --- a/lib/crypto/pgp/pgp.go +++ b/lib/crypto/pgp/pgp.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" "github.com/ProtonMail/go-crypto/openpgp" "github.com/ProtonMail/go-crypto/openpgp/armor" @@ -29,7 +29,7 @@ var ( ) func (m *Mail) Init() error { - logging.Debugf("Initializing PGP keyring") + log.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/messageview.go b/lib/messageview.go index 8507880b..d7ff1908 100644 --- a/lib/messageview.go +++ b/lib/messageview.go @@ -10,7 +10,7 @@ import ( _ "github.com/emersion/go-message/charset" "git.sr.ht/~rjarry/aerc/lib/crypto" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/lib" "git.sr.ht/~rjarry/aerc/worker/types" @@ -158,9 +158,9 @@ func (msv *MessageStoreView) FetchBodyPart(part []int, cb func(io.Reader)) { reader, err := lib.FetchEntityPartReader(msg, part) if err != nil { errMsg := fmt.Errorf("Failed to fetch message part: %w", err) - logging.Errorf(errMsg.Error()) + log.Errorf(errMsg.Error()) if msv.message != nil { - logging.Warnf("Displaying raw message part") + log.Warnf("Displaying raw message part") reader = bytes.NewReader(msv.message) } else { reader = strings.NewReader(errMsg.Error()) diff --git a/lib/msgstore.go b/lib/msgstore.go index 4205ea10..4a68f808 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -9,7 +9,7 @@ import ( "git.sr.ht/~rjarry/aerc/lib/marker" "git.sr.ht/~rjarry/aerc/lib/sort" "git.sr.ht/~rjarry/aerc/lib/ui" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -420,7 +420,7 @@ func (store *MessageStore) runThreadBuilder() { } if store.threadBuilderDebounce != nil { if store.threadBuilderDebounce.Stop() { - logging.Tracef("thread builder debounced") + log.Tracef("thread builder debounced") } } store.threadBuilderDebounce = time.AfterFunc(store.threadBuilderDelay, func() { @@ -469,7 +469,7 @@ func (store *MessageStore) SelectedThread() *types.Thread { return nil }) if err != nil { - logging.Errorf("SelectedThread failed: %v", err) + log.Errorf("SelectedThread failed: %v", err) } if found { break diff --git a/lib/open.go b/lib/open.go index 9faa6d10..2a4bdbcf 100644 --- a/lib/open.go +++ b/lib/open.go @@ -6,7 +6,7 @@ import ( "runtime" "strings" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" ) func XDGOpen(uri string) error { @@ -46,10 +46,10 @@ func XDGOpenMime( args = append(args, uri) } - logging.Tracef("running command: %v", args) + log.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) + log.Debugf("command: %v exited. err=%v out=%s", args, err, out) if err != nil { return fmt.Errorf("%v: %w", args, err) } diff --git a/lib/parse/ansi.go b/lib/parse/ansi.go index 265ef1f4..e1d603ea 100644 --- a/lib/parse/ansi.go +++ b/lib/parse/ansi.go @@ -8,7 +8,7 @@ import ( "os" "regexp" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" ) var ansi = regexp.MustCompile("\x1B\\[[0-?]*[ -/]*[@-~]") @@ -23,11 +23,11 @@ func StripAnsi(r io.Reader) io.Reader { line = ansi.ReplaceAll(line, []byte("")) _, err := buf.Write(line) if err != nil { - logging.Warnf("failed write ", err) + log.Warnf("failed write ", err) } _, err = buf.Write([]byte("\n")) if err != nil { - logging.Warnf("failed write ", err) + log.Warnf("failed write ", err) } } if err := scanner.Err(); err != nil { diff --git a/lib/socket.go b/lib/socket.go index 1cfd0583..5a41d910 100644 --- a/lib/socket.go +++ b/lib/socket.go @@ -12,7 +12,7 @@ import ( "sync/atomic" "time" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" "github.com/kyoh86/xdg" ) @@ -28,7 +28,7 @@ func StartServer() (*AercServer, error) { if err := ConnectAndExec(""); err != nil { os.Remove(sockpath) } - logging.Debugf("Starting Unix server: %s", sockpath) + log.Debugf("Starting Unix server: %s", sockpath) l, err := net.Listen("unix", sockpath) if err != nil { return nil, err @@ -36,7 +36,7 @@ func StartServer() (*AercServer, error) { as := &AercServer{listener: l} // TODO: stash clients and close them on exit... bleh racey go func() { - defer logging.PanicHandler() + defer log.PanicHandler() for { conn, err := l.Accept() @@ -46,12 +46,12 @@ func StartServer() (*AercServer, error) { // TODO: Something more useful, in some // cases, on wednesdays, after 2 PM, // I guess? - logging.Errorf("Closing Unix server: %v", err) + log.Errorf("Closing Unix server: %v", err) } return } go func() { - defer logging.PanicHandler() + defer log.PanicHandler() as.handleClient(conn) }() @@ -68,23 +68,23 @@ var lastId int64 = 0 // access via atomic func (as *AercServer) handleClient(conn net.Conn) { clientId := atomic.AddInt64(&lastId, 1) - logging.Debugf("unix:%d accepted connection", clientId) + log.Debugf("unix:%d accepted connection", clientId) scanner := bufio.NewScanner(conn) err := conn.SetDeadline(time.Now().Add(1 * time.Minute)) if err != nil { - logging.Errorf("failed to set deadline: %v", err) + log.Errorf("failed to set deadline: %v", err) } for scanner.Scan() { err = conn.SetDeadline(time.Now().Add(1 * time.Minute)) if err != nil { - logging.Errorf("failed to update deadline: %v", err) + log.Errorf("failed to update deadline: %v", err) } msg := scanner.Text() - logging.Tracef("unix:%d got message %s", clientId, msg) + log.Tracef("unix:%d got message %s", clientId, msg) if !strings.ContainsRune(msg, ':') { _, innererr := conn.Write([]byte("error: invalid command\n")) if innererr != nil { - logging.Errorf("failed to write error message: %v", innererr) + log.Errorf("failed to write error message: %v", innererr) } continue } @@ -96,14 +96,14 @@ func (as *AercServer) handleClient(conn net.Conn) { if err != nil { _, innererr := conn.Write([]byte(fmt.Sprintf("error: %v\n", err))) if innererr != nil { - logging.Errorf("failed to write error message: %v", innererr) + log.Errorf("failed to write error message: %v", innererr) } break } if as.OnMailto != nil { err = as.OnMailto(mailto) if err != nil { - logging.Errorf("mailto failed: %v", err) + log.Errorf("mailto failed: %v", err) } } case "mbox": @@ -114,16 +114,16 @@ func (as *AercServer) handleClient(conn net.Conn) { if err != nil { _, err = conn.Write([]byte(fmt.Sprintf("result: %v\n", err))) if err != nil { - logging.Errorf("failed to send error: %v") + log.Errorf("failed to send error: %v") } } else { _, err = conn.Write([]byte("result: success\n")) if err != nil { - logging.Errorf("failed to send successmessage: %v") + log.Errorf("failed to send successmessage: %v") } } } - logging.Tracef("unix:%d closed connection", clientId) + log.Tracef("unix:%d closed connection", clientId) } func ConnectAndExec(msg string) error { diff --git a/lib/threadbuilder.go b/lib/threadbuilder.go index 34f143a4..5a73397a 100644 --- a/lib/threadbuilder.go +++ b/lib/threadbuilder.go @@ -5,7 +5,7 @@ import ( "time" "git.sr.ht/~rjarry/aerc/lib/iterator" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/types" "github.com/gatherstars-com/jwz" @@ -67,7 +67,7 @@ func (builder *ThreadBuilder) Threads(uids []uint32, inverse bool, sort bool, builder.RebuildUids(threads, inverse) elapsed := time.Since(start) - logging.Tracef("%d threads from %d uids created in %s", len(threads), + log.Tracef("%d threads from %d uids created in %s", len(threads), len(uids), elapsed) return threads @@ -84,7 +84,7 @@ func (builder *ThreadBuilder) generateStructure(uids []uint32) jwz.Threadable { threader := jwz.NewThreader() threadStructure, err := threader.ThreadSlice(jwzThreads) if err != nil { - logging.Errorf("failed slicing threads: %v", err) + log.Errorf("failed slicing threads: %v", err) } return threadStructure } diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go index 8880c4c3..bcfe4a83 100644 --- a/lib/ui/textinput.go +++ b/lib/ui/textinput.go @@ -10,7 +10,7 @@ import ( "github.com/mattn/go-runewidth" "git.sr.ht/~rjarry/aerc/config" - "git.sr.ht/~rjarry/aerc/logging" + "git.sr.ht/~rjarry/aerc/log" ) // TODO: Attach history providers @@ -298,7 +298,7 @@ func (ti *TextInput) updateCompletions() { } if ti.completeDebouncer == nil { ti.completeDebouncer = time.AfterFunc(ti.completeDelay, func() { - defer logging.PanicHandler() + defer log.PanicHandler() ti.Lock() if len(ti.StringLeft()) >= ti.completeMinChars { ti.showCompletions() |