aboutsummaryrefslogtreecommitdiffstats
path: root/config/config.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-11-19 14:34:10 +0100
committerRobin Jarry <robin@jarry.cc>2022-11-21 13:18:34 +0100
commite5f2fb08d8a7604aeef726698ef696874bcd2561 (patch)
tree6927564ae1f016abc16bb9c5041969092c3ba10c /config/config.go
parent9db3710dd73b6949321a028b4dc2dc2277e97ce0 (diff)
downloadaerc-e5f2fb08d8a7604aeef726698ef696874bcd2561.tar.gz
config: add log-file and log-level settings
Allow configuring persistent logging to file with a log level. When redirecting the output of aerc to a file these two settings are ignored and all messages are printed to stdout. Suggested-by: Moritz Poldrack <moritz@poldrack.dev> Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'config/config.go')
-rw-r--r--config/config.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/config/config.go b/config/config.go
index 049b305f..c4794cc1 100644
--- a/config/config.go
+++ b/config/config.go
@@ -2,6 +2,7 @@ package config
import (
"errors"
+ "fmt"
"log"
"os"
"path"
@@ -11,8 +12,6 @@ import (
"github.com/go-ini/ini"
"github.com/kyoh86/xdg"
"github.com/mitchellh/go-homedir"
-
- "git.sr.ht/~rjarry/aerc/logging"
)
type AercConfig struct {
@@ -119,14 +118,12 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
// if it doesn't exist copy over the template, then load
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
- logging.Debugf("%s not found, installing the system default", filename)
+ fmt.Printf("%s not found, installing the system default", filename)
if err := installTemplate(*root, "aerc.conf"); err != nil {
return nil, err
}
}
- logging.Infof("Parsing configuration from %s", filename)
-
file, err := ini.LoadSources(ini.LoadOptions{
KeyValueDelimiters: "=",
}, filename)
@@ -147,6 +144,9 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
Openers: make(map[string][]string),
}
+ if err := config.parseGeneral(file); err != nil {
+ return nil, err
+ }
if err := config.parseFilters(file); err != nil {
return nil, err
}
@@ -168,9 +168,6 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
if err := config.parseUi(file); err != nil {
return nil, err
}
- if err := config.parseGeneral(file); err != nil {
- return nil, err
- }
if err := config.parseTemplates(file); err != nil {
return nil, err
}