diff options
Diffstat (limited to 'config/general.go')
-rw-r--r-- | config/general.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/config/general.go b/config/general.go index e90deffe..7ea2509b 100644 --- a/config/general.go +++ b/config/general.go @@ -33,8 +33,11 @@ func parseGeneral(file *ini.File) error { if err := MapToStruct(file.Section("general"), General, true); err != nil { return err } + + useStdout := false if !isatty.IsTerminal(os.Stdout.Fd()) { logFile = os.Stdout + useStdout = true // redirected to file, force TRACE level General.LogLevel = log.TRACE } else if General.LogFile != "" { @@ -47,11 +50,17 @@ func parseGeneral(file *ini.File) error { logFile, err = os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o600) if err != nil { - return fmt.Errorf("log-file: %w", err) + return err } } - log.Init(logFile, General.LogLevel) + + err := log.Init(logFile, useStdout, General.LogLevel) + if err != nil { + return err + } + log.Debugf("aerc.conf: [general] %#v", General) + return nil } |