diff --git a/internal/logging/const.go b/internal/logging/const.go new file mode 100644 index 000000000..22e233feb --- /dev/null +++ b/internal/logging/const.go @@ -0,0 +1,3 @@ +package logging + +const logFormatJSON = "json" diff --git a/internal/logging/logger.go b/internal/logging/logger.go index b81ddd927..d0b1e8ae5 100644 --- a/internal/logging/logger.go +++ b/internal/logging/logger.go @@ -23,7 +23,7 @@ func InitializeLogger(format, filename string) error { stackLevels := []logrus.Level{logrus.PanicLevel, logrus.FatalLevel, logrus.ErrorLevel} logrus.AddHook(logrus_stack.NewHook(callerLevels, stackLevels)) - if format == "json" { + if format == logFormatJSON { logrus.SetFormatter(&logrus.JSONFormatter{}) } else { logrus.SetFormatter(&logrus.TextFormatter{}) @@ -36,6 +36,13 @@ func InitializeLogger(format, filename string) error { return err } + if format != logFormatJSON { + logrus.SetFormatter(&logrus.TextFormatter{ + DisableColors: true, + FullTimestamp: true, + }) + } + logrus.SetOutput(f) }