2020-12-09 15:31:34 +00:00
|
|
|
package logger
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/sirupsen/logrus"
|
2021-12-06 13:29:39 +00:00
|
|
|
"github.com/snyk/driftctl/build"
|
2020-12-09 15:31:34 +00:00
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
2021-02-10 13:25:07 +00:00
|
|
|
func getConfig() Config {
|
2020-12-09 15:31:34 +00:00
|
|
|
|
|
|
|
config := Config{
|
|
|
|
Level: logrus.WarnLevel,
|
|
|
|
ReportCaller: false,
|
|
|
|
Formatter: NewTextFormatter(4),
|
|
|
|
}
|
|
|
|
|
|
|
|
build := build.Build{}
|
|
|
|
if !build.IsRelease() {
|
|
|
|
config.Level = logrus.DebugLevel
|
|
|
|
}
|
|
|
|
|
|
|
|
if viper.IsSet("log_level") {
|
|
|
|
level, _ := logrus.ParseLevel(viper.GetString("log_level"))
|
|
|
|
config.Level = level
|
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|