mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-17 22:32:58 +02:00
allow a LOG_LEVEL env var to be set
This commit is contained in:
parent
f5c8aac97d
commit
39844ffef9
@ -35,6 +35,7 @@ type App struct {
|
|||||||
func newProductionLogger(config config.AppConfigurer) *logrus.Logger {
|
func newProductionLogger(config config.AppConfigurer) *logrus.Logger {
|
||||||
log := logrus.New()
|
log := logrus.New()
|
||||||
log.Out = ioutil.Discard
|
log.Out = ioutil.Discard
|
||||||
|
log.SetLevel(logrus.ErrorLevel)
|
||||||
return log
|
return log
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,8 +45,18 @@ func globalConfigDir() string {
|
|||||||
return configDir.Path
|
return configDir.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getLogLevel() logrus.Level {
|
||||||
|
strLevel := os.Getenv("LOG_LEVEL")
|
||||||
|
level, err := logrus.ParseLevel(strLevel)
|
||||||
|
if err != nil {
|
||||||
|
return logrus.DebugLevel
|
||||||
|
}
|
||||||
|
return level
|
||||||
|
}
|
||||||
|
|
||||||
func newDevelopmentLogger(config config.AppConfigurer) *logrus.Logger {
|
func newDevelopmentLogger(config config.AppConfigurer) *logrus.Logger {
|
||||||
log := logrus.New()
|
log := logrus.New()
|
||||||
|
log.SetLevel(getLogLevel())
|
||||||
file, err := os.OpenFile(filepath.Join(globalConfigDir(), "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 {
|
if err != nil {
|
||||||
panic("unable to log to file") // TODO: don't panic (also, remove this call to the `panic` function)
|
panic("unable to log to file") // TODO: don't panic (also, remove this call to the `panic` function)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user