diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-13 21:16:21 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-13 21:16:21 +1000 |
commit | 9e725ae24e8fcecefec35a65b50476d371653ffb (patch) | |
tree | 840df3748f981967a3b9f7c276602832dab360d3 /pkg/app | |
parent | 97cff656121270e9c790432e28622d92ab7b0f1a (diff) |
got this bad boy compiling again
Diffstat (limited to 'pkg/app')
-rw-r--r-- | pkg/app/app.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go index b6318b745..011375737 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -2,9 +2,9 @@ package app import ( "io" + "os" "github.com/Sirupsen/logrus" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui" @@ -18,7 +18,21 @@ type App struct { Log *logrus.Logger OSCommand *commands.OSCommand GitCommand *commands.GitCommand - Gui *gocui.Gui + Gui *gui.Gui +} + +func newLogger(config config.AppConfigurer) *logrus.Logger { + log := logrus.New() + if !config.GetDebug() { + log.Out = nil + return log + } + file, err := os.OpenFile("development.log", os.O_CREATE|os.O_WRONLY, 0666) + if err != nil { + panic("unable to log to file") // TODO: don't panic (also, remove this call to the `panic` function) + } + log.Out = file + return log } // NewApp retruns a new applications @@ -28,7 +42,7 @@ func NewApp(config config.AppConfigurer) (*App, error) { Config: config, } var err error - app.Log = logrus.New() + app.Log = newLogger(config) app.OSCommand, err = commands.NewOSCommand(app.Log) if err != nil { return nil, err @@ -37,7 +51,7 @@ func NewApp(config config.AppConfigurer) (*App, error) { if err != nil { return nil, err } - app.Gui, err = gui.NewGui(app.Log, app.GitCommand, config.GetVersion()) + app.Gui, err = gui.NewGui(app.Log, app.GitCommand, app.OSCommand, config.GetVersion()) if err != nil { return nil, err } |