aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-11-27 11:29:34 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-02 22:10:49 +0100
commit23a05d17ac1d23466ff73efa19576d43d06efe4b (patch)
tree49986587a62bdd89eb06ffa2aadf05f6d45cb3e7 /widgets
parent70f46757449c8f24b818f4dfc5dcb87da7e327d6 (diff)
downloadaerc-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 'widgets')
-rw-r--r--widgets/account.go18
-rw-r--r--widgets/aerc.go10
-rw-r--r--widgets/compose.go30
-rw-r--r--widgets/dirlist.go6
-rw-r--r--widgets/dirtree.go6
-rw-r--r--widgets/listbox.go4
-rw-r--r--widgets/msglist.go4
-rw-r--r--widgets/msgviewer.go22
-rw-r--r--widgets/spinner.go4
-rw-r--r--widgets/status.go4
-rw-r--r--widgets/terminal.go4
11 files changed, 56 insertions, 56 deletions
diff --git a/widgets/account.go b/widgets/account.go
index ca899c93..c8c58b1e 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -14,7 +14,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib/sort"
"git.sr.ht/~rjarry/aerc/lib/statusline"
"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"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -83,7 +83,7 @@ func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountCon
worker, err := worker.NewWorker(acct.Source, acct.Name)
if err != nil {
host.SetError(fmt.Sprintf("%s: %s", acct.Name, err))
- logging.Errorf("%s: %v", acct.Name, err)
+ log.Errorf("%s: %v", acct.Name, err)
return view, err
}
view.worker = worker
@@ -97,7 +97,7 @@ func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountCon
view.grid.AddChild(view.msglist).At(0, 1)
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
if deferLoop != nil {
<-deferLoop
@@ -235,7 +235,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
switch msg.InResponseTo().(type) {
case *types.Connect, *types.Reconnect:
acct.SetStatus(statusline.ConnectionActivity("Listing mailboxes..."))
- logging.Tracef("Listing mailboxes...")
+ log.Tracef("Listing mailboxes...")
acct.dirlist.UpdateList(func(dirs []string) {
var dir string
for _, _dir := range dirs {
@@ -251,14 +251,14 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
acct.dirlist.Select(dir)
}
acct.msglist.SetInitDone()
- logging.Infof("[%s] connected.", acct.acct.Name)
+ log.Infof("[%s] connected.", acct.acct.Name)
acct.SetStatus(statusline.SetConnected(true))
acct.newConn = true
})
case *types.Disconnect:
acct.dirlist.ClearList()
acct.msglist.SetStore(nil)
- logging.Infof("[%s] disconnected.", acct.acct.Name)
+ log.Infof("[%s] disconnected.", acct.acct.Name)
acct.SetStatus(statusline.SetConnected(false))
case *types.OpenDirectory:
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
@@ -347,13 +347,13 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
case *types.LabelList:
acct.labels = msg.Labels
case *types.ConnError:
- logging.Errorf("[%s] connection error: %v", acct.acct.Name, msg.Error)
+ log.Errorf("[%s] connection error: %v", acct.acct.Name, msg.Error)
acct.SetStatus(statusline.SetConnected(false))
acct.PushError(msg.Error)
acct.msglist.SetStore(nil)
acct.worker.PostAction(&types.Reconnect{}, nil)
case *types.Error:
- logging.Errorf("[%s] unexpected error: %v", acct.acct.Name, msg.Error)
+ log.Errorf("[%s] unexpected error: %v", acct.acct.Name, msg.Error)
acct.PushError(msg.Error)
}
acct.UpdateStatus()
@@ -427,7 +427,7 @@ func (acct *AccountView) CheckMail() {
dirs := acct.dirlist.List()
dirs = acct.dirlist.FilterDirs(dirs, acct.AccountConfig().CheckMailInclude, false)
dirs = acct.dirlist.FilterDirs(dirs, exclude, true)
- logging.Debugf("Checking for new mail on account %s", acct.Name())
+ log.Debugf("Checking for new mail on account %s", acct.Name())
acct.SetStatus(statusline.ConnectionActivity("Checking for new mail..."))
msg := &types.CheckMail{
Directories: dirs,
diff --git a/widgets/aerc.go b/widgets/aerc.go
index dce28c3e..ca82ee28 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -19,7 +19,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/crypto"
"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"
)
@@ -139,11 +139,11 @@ func (aerc *Aerc) OnBeep(f func() error) {
func (aerc *Aerc) Beep() {
if aerc.beep == nil {
- logging.Warnf("should beep, but no beeper")
+ log.Warnf("should beep, but no beeper")
return
}
if err := aerc.beep(); err != nil {
- logging.Errorf("tried to beep, but could not: %v", err)
+ log.Errorf("tried to beep, but could not: %v", err)
}
}
@@ -750,7 +750,7 @@ func (aerc *Aerc) Mbox(source string) error {
acctConf = *selectedAcct.acct
info := fmt.Sprintf("Loading outgoing mbox mail settings from account [%s]", selectedAcct.Name())
aerc.PushStatus(info, 10*time.Second)
- logging.Debugf(info)
+ log.Debugf(info)
} else {
acctConf.From = "<user@localhost>"
}
@@ -782,7 +782,7 @@ func (aerc *Aerc) CloseBackends() error {
err := c.Close()
if err != nil {
returnErr = err
- logging.Errorf("Closing backend failed for %s: %v", acct.Name(), err)
+ log.Errorf("Closing backend failed for %s: %v", acct.Name(), err)
}
}
return returnErr
diff --git a/widgets/compose.go b/widgets/compose.go
index 1bbdb477..c52c381f 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -23,7 +23,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib/format"
"git.sr.ht/~rjarry/aerc/lib/templates"
"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"
)
@@ -109,7 +109,7 @@ func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
func (c *Composer) SwitchAccount(newAcct *AccountView) error {
if c.acct == newAcct {
- logging.Tracef("same accounts: no switch")
+ log.Tracef("same accounts: no switch")
return nil
}
// sync the header with the editors
@@ -127,7 +127,7 @@ func (c *Composer) SwitchAccount(newAcct *AccountView) error {
editor.loadValue()
}
c.Invalidate()
- logging.Debugf("account sucessfully switched")
+ log.Debugf("account sucessfully switched")
return nil
}
@@ -158,7 +158,7 @@ func (c *Composer) setupFor(acct *AccountView) error {
cmpl := completer.New(cmd, func(err error) {
c.aerc.PushError(
fmt.Sprintf("could not complete header: %v", err))
- logging.Errorf("could not complete header: %v", err)
+ log.Errorf("could not complete header: %v", err)
})
c.completer = cmpl
@@ -188,7 +188,7 @@ func (c *Composer) setupFor(acct *AccountView) error {
c.sign = false
if c.acctConfig.PgpAutoSign {
err := c.SetSign(true)
- logging.Warnf("failed to enable message signing: %v", err)
+ log.Warnf("failed to enable message signing: %v", err)
}
c.encrypt = false
if c.acctConfig.PgpOpportunisticEncrypt {
@@ -196,7 +196,7 @@ func (c *Composer) setupFor(acct *AccountView) error {
}
err := c.updateCrypto()
if err != nil {
- logging.Warnf("failed to update crypto: %v", err)
+ log.Warnf("failed to update crypto: %v", err)
}
return nil
@@ -351,7 +351,7 @@ func (c *Composer) SetEncrypt(encrypt bool) *Composer {
c.encrypt = encrypt
err := c.updateCrypto()
if err != nil {
- logging.Warnf("failed to update crypto: %v", err)
+ log.Warnf("failed to update crypto: %v", err)
}
return c
}
@@ -427,19 +427,19 @@ func (c *Composer) updateCrypto() error {
func (c *Composer) SetContents(reader io.Reader) *Composer {
_, err := c.email.Seek(0, io.SeekStart)
if err != nil {
- logging.Warnf("failed to seek beginning of mail: %v", err)
+ log.Warnf("failed to seek beginning of mail: %v", err)
}
_, err = io.Copy(c.email, reader)
if err != nil {
- logging.Warnf("failed to copy mail: %v", err)
+ log.Warnf("failed to copy mail: %v", err)
}
err = c.email.Sync()
if err != nil {
- logging.Warnf("failed to sync mail: %v", err)
+ log.Warnf("failed to sync mail: %v", err)
}
_, err = c.email.Seek(0, io.SeekStart)
if err != nil {
- logging.Warnf("failed to seek beginning of mail after sync: %v", err)
+ log.Warnf("failed to seek beginning of mail after sync: %v", err)
}
return c
}
@@ -447,15 +447,15 @@ func (c *Composer) SetContents(reader io.Reader) *Composer {
func (c *Composer) AppendContents(reader io.Reader) {
_, err := c.email.Seek(0, io.SeekEnd)
if err != nil {
- logging.Warnf("failed to seek beginning of mail: %v", err)
+ log.Warnf("failed to seek beginning of mail: %v", err)
}
_, err = io.Copy(c.email, reader)
if err != nil {
- logging.Warnf("failed to copy mail: %v", err)
+ log.Warnf("failed to copy mail: %v", err)
}
err = c.email.Sync()
if err != nil {
- logging.Warnf("failed to sync mail: %v", err)
+ log.Warnf("failed to sync mail: %v", err)
}
}
@@ -1415,7 +1415,7 @@ func (c *Composer) checkEncryptionKeys(_ string) bool {
c.encrypt = true
err = c.updateCrypto()
if err != nil {
- logging.Warnf("failed update crypto: %v", err)
+ log.Warnf("failed update crypto: %v", err)
}
return true
}
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 4663d487..e4f867eb 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -18,7 +18,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/format"
"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"
)
@@ -155,7 +155,7 @@ func (dirlist *DirectoryList) Select(name string) {
delay := dirlist.UiConfig(name).DirListDelay
go func(ctx context.Context) {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
select {
case <-time.After(delay):
@@ -187,7 +187,7 @@ func (dirlist *DirectoryList) Select(name string) {
})
dirlist.Invalidate()
case <-ctx.Done():
- logging.Tracef("dirlist: skip %s", name)
+ log.Tracef("dirlist: skip %s", name)
return
}
}(ctx)
diff --git a/widgets/dirtree.go b/widgets/dirtree.go
index 8a3dab6f..e9fbf061 100644
--- a/widgets/dirtree.go
+++ b/widgets/dirtree.go
@@ -9,7 +9,7 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/ui"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/worker/types"
"github.com/gdamore/tcell/v2"
)
@@ -389,7 +389,7 @@ func (dt *DirectoryTree) buildTree() {
return nil
})
if err != nil {
- logging.Warnf("failed to walk tree: %v", err)
+ log.Warnf("failed to walk tree: %v", err)
}
}
}
@@ -455,7 +455,7 @@ func getAnyUid(node *types.Thread) (uid uint32) {
return nil
})
if err != nil {
- logging.Warnf("failed to get uid: %v", err)
+ log.Warnf("failed to get uid: %v", err)
}
return
}
diff --git a/widgets/listbox.go b/widgets/listbox.go
index 8f4f7123..9a0a48bc 100644
--- a/widgets/listbox.go
+++ b/widgets/listbox.go
@@ -7,7 +7,7 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/ui"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
)
@@ -58,7 +58,7 @@ func (lb *ListBox) dedup() {
dedup := make(map[string]struct{})
for _, line := range lb.lines {
if _, dup := dedup[line]; dup {
- logging.Warnf("ignore duplicate: %s", line)
+ log.Warnf("ignore duplicate: %s", line)
continue
}
dedup[line] = struct{}{}
diff --git a/widgets/msglist.go b/widgets/msglist.go
index ef29724a..09ee705e 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -14,7 +14,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib/format"
"git.sr.ht/~rjarry/aerc/lib/iterator"
"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"
)
@@ -119,7 +119,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
return nil
})
if err != nil {
- logging.Errorf("thread walk: %v", err)
+ log.Errorf("thread walk: %v", err)
}
for curIter := factory.NewIterator(cur); curIter.Next(); {
if i < ml.Scroll() {
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 019f9d6e..6c929578 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -20,7 +20,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib/format"
"git.sr.ht/~rjarry/aerc/lib/parse"
"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"
)
@@ -240,7 +240,7 @@ func createSwitcher(acct *AccountView, switcher *PartSwitcher,
return err
}
selectedPriority := -1
- logging.Tracef("Selecting best message from %v", conf.Viewer.Alternatives)
+ log.Tracef("Selecting best message from %v", conf.Viewer.Alternatives)
for i, pv := range switcher.parts {
// Switch to user's preferred mimetype
if switcher.selected == -1 && pv.part.MIMEType != "multipart" {
@@ -312,7 +312,7 @@ func (mv *MessageViewer) ToggleHeaders() {
mv.conf.Viewer.ShowHeaders = !mv.conf.Viewer.ShowHeaders
err := createSwitcher(mv.acct, switcher, mv.conf, mv.msg)
if err != nil {
- logging.Errorf("cannot create switcher: %v", err)
+ log.Errorf("cannot create switcher: %v", err)
}
switcher.Invalidate()
}
@@ -603,7 +603,7 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig,
fmt.Sprintf("AERC_SUBJECT=%s", info.Envelope.Subject))
filter.Env = append(filter.Env, fmt.Sprintf("AERC_FROM=%s",
format.FormatAddresses(info.Envelope.From)))
- logging.Debugf("<%s> part=%v %s: %v | %v",
+ log.Debugf("<%s> part=%v %s: %v | %v",
info.Envelope.MessageId, curindex, mime, filter, pager)
if pagerin, err = pager.StdinPipe(); err != nil {
return nil, err
@@ -668,20 +668,20 @@ func (pv *PartViewer) attemptCopy() {
pv.filter.Stderr = pv.pagerin
err := pv.filter.Start()
if err != nil {
- logging.Errorf("error running filter: %v", err)
+ log.Errorf("error running filter: %v", err)
return
}
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
defer atomic.StoreInt32(&pv.copying, 0)
err = pv.filter.Wait()
if err != nil {
- logging.Errorf("error waiting for filter: %v", err)
+ log.Errorf("error waiting for filter: %v", err)
return
}
err = pv.pagerin.Close()
if err != nil {
- logging.Errorf("error closing pager pipe: %v", err)
+ log.Errorf("error closing pager pipe: %v", err)
return
}
}()
@@ -705,7 +705,7 @@ func (pv *PartViewer) writeMailHeaders() {
"%s: %s\n", fields.Key(), value)
_, err = pv.pagerin.Write([]byte(field))
if err != nil {
- logging.Errorf("failed to write to stdin of pager: %v", err)
+ log.Errorf("failed to write to stdin of pager: %v", err)
}
}
// virtual header
@@ -713,12 +713,12 @@ func (pv *PartViewer) writeMailHeaders() {
labels := fmtHeader(info, "Labels", "", "", "", "")
_, err := pv.pagerin.Write([]byte(fmt.Sprintf("Labels: %s\n", labels)))
if err != nil {
- logging.Errorf("failed to write to stdin of pager: %v", err)
+ log.Errorf("failed to write to stdin of pager: %v", err)
}
}
_, err := pv.pagerin.Write([]byte{'\n'})
if err != nil {
- logging.Errorf("failed to write to stdin of pager: %v", err)
+ log.Errorf("failed to write to stdin of pager: %v", err)
}
}
}
diff --git a/widgets/spinner.go b/widgets/spinner.go
index cddbacd5..99365527 100644
--- a/widgets/spinner.go
+++ b/widgets/spinner.go
@@ -9,7 +9,7 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/ui"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
)
type Spinner struct {
@@ -37,7 +37,7 @@ func (s *Spinner) Start() {
atomic.StoreInt64(&s.frame, 0)
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
for {
select {
diff --git a/widgets/status.go b/widgets/status.go
index a6fd5c8f..97ff9441 100644
--- a/widgets/status.go
+++ b/widgets/status.go
@@ -8,7 +8,7 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/ui"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
)
type StatusLine struct {
@@ -76,7 +76,7 @@ func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage
}
status.stack = append(status.stack, msg)
go (func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
time.Sleep(expiry)
for i, m := range status.stack {
diff --git a/widgets/terminal.go b/widgets/terminal.go
index b12a6a0a..9a2ebbef 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -5,7 +5,7 @@ import (
"syscall"
"git.sr.ht/~rjarry/aerc/lib/ui"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
tcellterm "git.sr.ht/~rockorager/tcell-term"
"github.com/gdamore/tcell/v2"
@@ -81,7 +81,7 @@ func (term *Terminal) Draw(ctx *ui.Context) {
term.vterm.Watch(term)
attr := &syscall.SysProcAttr{Setsid: true, Setctty: true, Ctty: 1}
if err := term.vterm.StartWithAttrs(term.cmd, attr); err != nil {
- logging.Errorf("error running terminal: %v", err)
+ log.Errorf("error running terminal: %v", err)
term.Close(err)
return
}