summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-01-16 08:46:05 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-01-16 08:54:12 +1100
commitc722ea5afcb47a823f76b2e8270f60534f1a9230 (patch)
tree83f8014c0b7022fc93c8fc03b61799a4e86c13a0
parentc759c7ac6537eb2ed8f65b566d898a2f2048f9d5 (diff)
log in config directory rather than wherever you opened lazygit
-rw-r--r--pkg/app/app.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index 74152b08b..ad5edca70 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -4,6 +4,7 @@ import (
"io"
"io/ioutil"
"os"
+ "path/filepath"
"github.com/heroku/rollrus"
"github.com/jesseduffield/lazygit/pkg/commands"
@@ -11,6 +12,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/updates"
+ "github.com/shibukawa/configdir"
"github.com/sirupsen/logrus"
)
@@ -33,9 +35,15 @@ func newProductionLogger(config config.AppConfigurer) *logrus.Logger {
return log
}
-func newDevelopmentLogger() *logrus.Logger {
+func globalConfigDir() string {
+ configDirs := configdir.New("jesseduffield", "lazygit")
+ configDir := configDirs.QueryFolders(configdir.Global)[0]
+ return configDir.Path
+}
+
+func newDevelopmentLogger(config config.AppConfigurer) *logrus.Logger {
log := logrus.New()
- file, err := os.OpenFile("development.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
+ file, err := os.OpenFile(filepath.Join(globalConfigDir(), "development.log"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
panic("unable to log to file") // TODO: don't panic (also, remove this call to the `panic` function)
}
@@ -48,7 +56,7 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
environment := "production"
if config.GetDebug() {
environment = "development"
- log = newDevelopmentLogger()
+ log = newDevelopmentLogger(config)
} else {
log = newProductionLogger(config)
}