|
|
@ -30,6 +30,7 @@ import ( |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"regexp" |
|
|
|
"regexp" |
|
|
|
"sort" |
|
|
|
"sort" |
|
|
|
|
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/spf13/cobra" |
|
|
|
"github.com/spf13/cobra" |
|
|
@ -147,22 +148,17 @@ func Execute() { |
|
|
|
|
|
|
|
|
|
|
|
// initLogging initializes the logger
|
|
|
|
// initLogging initializes the logger
|
|
|
|
func initLogging() { |
|
|
|
func initLogging() { |
|
|
|
|
|
|
|
l.Log().SetLevel(logrus.InfoLevel) // default log level: info
|
|
|
|
if flags.traceLogging { |
|
|
|
if flags.traceLogging { |
|
|
|
l.Log().SetLevel(logrus.TraceLevel) |
|
|
|
l.Log().SetLevel(logrus.TraceLevel) |
|
|
|
} else if flags.debugLogging { |
|
|
|
} else if flags.debugLogging { |
|
|
|
l.Log().SetLevel(logrus.DebugLevel) |
|
|
|
l.Log().SetLevel(logrus.DebugLevel) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
switch logLevel := strings.ToUpper(os.Getenv("LOG_LEVEL")); logLevel { |
|
|
|
if ll := os.Getenv("LOG_LEVEL"); ll != "" { |
|
|
|
case "TRACE": |
|
|
|
level, err := logrus.ParseLevel(ll) |
|
|
|
l.Log().SetLevel(logrus.TraceLevel) |
|
|
|
if err != nil { |
|
|
|
case "DEBUG": |
|
|
|
l.Log().SetLevel(level) |
|
|
|
l.Log().SetLevel(logrus.DebugLevel) |
|
|
|
} |
|
|
|
case "WARN": |
|
|
|
|
|
|
|
l.Log().SetLevel(logrus.WarnLevel) |
|
|
|
|
|
|
|
case "ERROR": |
|
|
|
|
|
|
|
l.Log().SetLevel(logrus.ErrorLevel) |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
l.Log().SetLevel(logrus.InfoLevel) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
l.Log().SetOutput(io.Discard) |
|
|
|
l.Log().SetOutput(io.Discard) |
|
|
@ -188,6 +184,10 @@ func initLogging() { |
|
|
|
ForceColors: true, |
|
|
|
ForceColors: true, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if logColor, err := strconv.ParseBool(os.Getenv("LOG_COLORS")); err == nil { |
|
|
|
|
|
|
|
formatter.ForceColors = logColor |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if flags.timestampedLogging || os.Getenv("LOG_TIMESTAMPS") != "" { |
|
|
|
if flags.timestampedLogging || os.Getenv("LOG_TIMESTAMPS") != "" { |
|
|
|
formatter.FullTimestamp = true |
|
|
|
formatter.FullTimestamp = true |
|
|
|
} |
|
|
|
} |
|
|
|