logging: use level-based logger functions
Do not pass logger objects around anymore. Shuffle some messages to make them consistent with the new logging API. Avoid using %v when a more specific verb exists for the argument types. The loggers are completely disabled (i.e. Sprintf is not even called) by default. They are only enabled when redirecting stdout to a file. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
parent
a1f779ccc9
commit
cd19995557
43 changed files with 268 additions and 342 deletions
commands/msg
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
"git.sr.ht/~rjarry/aerc/lib"
|
||||
"git.sr.ht/~rjarry/aerc/lib/format"
|
||||
"git.sr.ht/~rjarry/aerc/logging"
|
||||
"git.sr.ht/~rjarry/aerc/models"
|
||||
"git.sr.ht/~rjarry/aerc/widgets"
|
||||
"git.sr.ht/~rjarry/aerc/worker/types"
|
||||
|
@ -73,7 +74,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
acct.Logger().Println("Forwarding email " + msg.Envelope.MessageId)
|
||||
logging.Infof("Forwarding email %s", msg.Envelope.MessageId)
|
||||
|
||||
h := &mail.Header{}
|
||||
subject := "Fwd: " + msg.Envelope.Subject
|
||||
|
@ -187,7 +188,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
bs, err := msg.BodyStructure.PartAtIndex(p)
|
||||
if err != nil {
|
||||
acct.Logger().Println("forward: PartAtIndex:", err)
|
||||
logging.Errorf("cannot get PartAtIndex %v: %v", p, err)
|
||||
continue
|
||||
}
|
||||
store.FetchBodyPart(msg.Uid, p, func(reader io.Reader) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
"git.sr.ht/~rjarry/aerc/lib"
|
||||
"git.sr.ht/~rjarry/aerc/logging"
|
||||
"git.sr.ht/~rjarry/aerc/models"
|
||||
"git.sr.ht/~rjarry/aerc/widgets"
|
||||
"git.sr.ht/~rjarry/aerc/worker/types"
|
||||
|
@ -69,7 +70,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "Recall failed")
|
||||
}
|
||||
acct.Logger().Println("Recalling message " + msgInfo.Envelope.MessageId)
|
||||
logging.Infof("Recalling message %s", msgInfo.Envelope.MessageId)
|
||||
|
||||
composer, err := widgets.NewComposer(aerc, acct, aerc.Config(),
|
||||
acct.AccountConfig(), acct.Worker(), "", msgInfo.RFC822Headers,
|
||||
|
@ -197,7 +198,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
bs, err := msg.BodyStructure().PartAtIndex(p)
|
||||
if err != nil {
|
||||
acct.Logger().Println("recall: PartAtIndex:", err)
|
||||
logging.Infof("cannot get PartAtIndex %v: %v", p, err)
|
||||
continue
|
||||
}
|
||||
msg.FetchBodyPart(p, func(reader io.Reader) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"git.sr.ht/~rjarry/aerc/lib"
|
||||
"git.sr.ht/~rjarry/aerc/logging"
|
||||
"git.sr.ht/~rjarry/aerc/models"
|
||||
"git.sr.ht/~rjarry/aerc/widgets"
|
||||
"github.com/emersion/go-message/mail"
|
||||
|
@ -54,10 +55,10 @@ func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(methods) == 0 {
|
||||
return fmt.Errorf("no methods found to unsubscribe")
|
||||
}
|
||||
aerc.Logger().Printf("unsubscribe: found %d methods", len(methods))
|
||||
logging.Infof("unsubscribe: found %d methods", len(methods))
|
||||
|
||||
unsubscribe := func(method *url.URL) {
|
||||
aerc.Logger().Printf("unsubscribe: trying to unsubscribe using %v", method.Scheme)
|
||||
logging.Infof("unsubscribe: trying to unsubscribe using %s", method.Scheme)
|
||||
var err error
|
||||
switch strings.ToLower(method.Scheme) {
|
||||
case "mailto":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue