logging: print init procedure and config contents

This may help debugging issues.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
Robin Jarry 2022-07-19 21:11:33 +02:00
parent cd19995557
commit 9203c4b6ef
2 changed files with 29 additions and 5 deletions

View File

@ -95,15 +95,19 @@ func usage(msg string) {
} }
func setWindowTitle() { func setWindowTitle() {
logging.Debugf("Parsing terminfo")
ti, err := terminfo.LoadFromEnv() ti, err := terminfo.LoadFromEnv()
if err != nil { if err != nil {
logging.Warnf("Cannot get terminfo: %v", err)
return return
} }
if !ti.Has(terminfo.HasStatusLine) { if !ti.Has(terminfo.HasStatusLine) {
logging.Infof("Terminal does not have status line support")
return return
} }
logging.Infof("Setting terminal title")
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
ti.Fprintf(buf, terminfo.ToStatusLine) ti.Fprintf(buf, terminfo.ToStatusLine)
fmt.Fprint(buf, "aerc") fmt.Fprint(buf, "aerc")

View File

@ -659,11 +659,14 @@ func LoadConfigFromFile(root *string) (*AercConfig, error) {
// if it doesn't exist copy over the template, then load // if it doesn't exist copy over the template, then load
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) { if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
logging.Debugf("%s not found, installing the system default", filename)
if err := installTemplate(*root, "aerc.conf"); err != nil { if err := installTemplate(*root, "aerc.conf"); err != nil {
return nil, err return nil, err
} }
} }
logging.Infof("Parsing configuration from %s", filename)
file, err := ini.LoadSources(ini.LoadOptions{ file, err := ini.LoadSources(ini.LoadOptions{
KeyValueDelimiters: "=", KeyValueDelimiters: "=",
}, filename) }, filename)
@ -788,6 +791,15 @@ func LoadConfigFromFile(root *string) (*AercConfig, error) {
} }
} }
logging.Debugf("aerc.conf: [general] %#v", config.General)
logging.Debugf("aerc.conf: [ui] %#v", config.Ui)
logging.Debugf("aerc.conf: [statusline] %#v", config.Statusline)
logging.Debugf("aerc.conf: [viewer] %#v", config.Viewer)
logging.Debugf("aerc.conf: [compose] %#v", config.Compose)
logging.Debugf("aerc.conf: [filters] %#v", config.Filters)
logging.Debugf("aerc.conf: [triggers] %#v", config.Triggers)
logging.Debugf("aerc.conf: [templates] %#v", config.Templates)
filename = path.Join(*root, "accounts.conf") filename = path.Join(*root, "accounts.conf")
if !config.General.UnsafeAccountsConf { if !config.General.UnsafeAccountsConf {
if err := checkConfigPerms(filename); err != nil { if err := checkConfigPerms(filename); err != nil {
@ -796,21 +808,28 @@ func LoadConfigFromFile(root *string) (*AercConfig, error) {
} }
accountsPath := path.Join(*root, "accounts.conf") accountsPath := path.Join(*root, "accounts.conf")
logging.Infof("Parsing accounts configuration from %s", accountsPath)
if accounts, err := loadAccountConfig(accountsPath); err != nil { if accounts, err := loadAccountConfig(accountsPath); err != nil {
return nil, err return nil, err
} else { } else {
config.Accounts = accounts config.Accounts = accounts
} }
for _, acct := range config.Accounts {
logging.Debugf("accounts.conf: [%s] from = %s", acct.Name, acct.From)
}
filename = path.Join(*root, "binds.conf") filename = path.Join(*root, "binds.conf")
binds, err := ini.Load(filename) if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
if err != nil { logging.Debugf("%s not found, installing the system default", filename)
if err := installTemplate(*root, "binds.conf"); err != nil { if err := installTemplate(*root, "binds.conf"); err != nil {
return nil, err return nil, err
} }
if binds, err = ini.Load(filename); err != nil {
return nil, err
} }
logging.Infof("Parsing key bindings configuration from %s", filename)
binds, err := ini.Load(filename)
if err != nil {
return nil, err
} }
baseGroups := map[string]**KeyBindings{ baseGroups := map[string]**KeyBindings{
@ -851,6 +870,7 @@ func LoadConfigFromFile(root *string) (*AercConfig, error) {
contextBind.Bindings.Globals = false contextBind.Bindings.Globals = false
} }
} }
logging.Debugf("binds.conf: %#v", config.Bindings)
return config, nil return config, nil
} }