summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-07-19 22:31:51 +0200
committerRobin Jarry <robin@jarry.cc>2022-07-23 22:52:15 +0200
commitcd1999555714fb886493d2d04b6c472be55cebef (patch)
tree1df3bcf5f687752db671d8bc9c7eab8a5c0fde71 /config
parenta1f779ccc9b16b22ad6cb2e0bf73c290fd0cc756 (diff)
downloadaerc-cd1999555714fb886493d2d04b6c472be55cebef.zip
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>
Diffstat (limited to 'config')
-rw-r--r--config/config.go9
-rw-r--r--config/triggers.go3
2 files changed, 7 insertions, 5 deletions
diff --git a/config/config.go b/config/config.go
index ebdee5e..22bbe2b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -23,6 +23,7 @@ import (
"github.com/mitchellh/go-homedir"
"git.sr.ht/~rjarry/aerc/lib/templates"
+ "git.sr.ht/~rjarry/aerc/logging"
)
type GeneralConfig struct {
@@ -649,7 +650,7 @@ func validatePgpProvider(section *ini.Section) error {
return nil
}
-func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) {
+func LoadConfigFromFile(root *string) (*AercConfig, error) {
if root == nil {
_root := path.Join(xdg.ConfigHome(), "aerc")
root = &_root
@@ -837,7 +838,7 @@ func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) {
}
if baseOnly {
- err = config.LoadBinds(binds, baseSectionName, group, logger)
+ err = config.LoadBinds(binds, baseSectionName, group)
if err != nil {
return nil, err
}
@@ -887,7 +888,7 @@ func LoadBindingSection(sec *ini.Section) (*KeyBindings, error) {
return bindings, nil
}
-func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup **KeyBindings, logger *log.Logger) error {
+func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup **KeyBindings) error {
if sec, err := binds.GetSection(baseName); err == nil {
binds, err := LoadBindingSection(sec)
@@ -942,7 +943,7 @@ func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup
}
}
if !valid {
- logger.Printf("Tried to define binds for unexistent account: %v\n", acctName)
+ logging.Warnf("binds.conf: unexistent account: %s", acctName)
continue
}
contextualBind.ContextType = BIND_CONTEXT_ACCOUNT
diff --git a/config/triggers.go b/config/triggers.go
index 3005d59..daf4373 100644
--- a/config/triggers.go
+++ b/config/triggers.go
@@ -7,6 +7,7 @@ import (
"github.com/google/shlex"
"git.sr.ht/~rjarry/aerc/lib/format"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
)
@@ -52,6 +53,6 @@ func (trig *TriggersConfig) ExecNewEmail(account *AccountConfig,
return fmt.Sprintf(formatstr, args...), nil
})
if err != nil {
- fmt.Printf("Error from the new-email trigger: %s\n", err)
+ logging.Errorf("failed to run new-email trigger: %v", err)
}
}