diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-01-31 21:18:21 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-01-31 21:18:21 -0500 |
commit | a21afdaa6bab8f6d05bbe9272700eef571548a59 (patch) | |
tree | 82149576ffdb6c13bf1a1ac2f1abb729e79cf3c9 /cmd | |
parent | 1710c9054898e820700d673e21e7c7a90a3f67b1 (diff) |
Improve logging
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/aerc/main.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/cmd/aerc/main.go b/cmd/aerc/main.go index e33f158..cda4991 100644 --- a/cmd/aerc/main.go +++ b/cmd/aerc/main.go @@ -1,13 +1,30 @@ package main import ( + "fmt" + "io" + "io/ioutil" + "log" + "os" "time" + "github.com/mattn/go-isatty" + "git.sr.ht/~sircmpwn/aerc2/config" "git.sr.ht/~sircmpwn/aerc2/ui" ) func main() { + var logOut io.Writer + var logger *log.Logger + if !isatty.IsTerminal(os.Stdout.Fd()) { + logOut = os.Stdout + } else { + logOut = ioutil.Discard + } + logger = log.New(logOut, "", log.LstdFlags|log.Lshortfile) + logger.Println("Starting up aerc") + conf, err := config.LoadConfig(nil) if err != nil { panic(err) @@ -18,7 +35,11 @@ func main() { } defer _ui.Close() for _, account := range conf.Accounts { - tab, err := ui.NewAccountTab(&account) + logger.Printf("Initializing account %s\n", account.Name) + tab, err := ui.NewAccountTab(&account, log.New( + logOut, + fmt.Sprintf("[%s] ", account.Name), + log.LstdFlags|log.Lshortfile)) if err != nil { panic(err) } |