diff --git a/internal/common/logging/application.go b/internal/common/logging/application.go index 279dbbc174d..e6da71ca89f 100644 --- a/internal/common/logging/application.go +++ b/internal/common/logging/application.go @@ -85,7 +85,7 @@ func createFileLogger(logConfig Config) (*FilteredLevelWriter, error) { Compress: logConfig.File.Rotation.Compress, } - if strings.ToLower(logConfig.File.Format) == "text" || strings.ToLower(logConfig.File.Format) == "colorful" { + if strings.ToLower(logConfig.File.Format) == "text" || strings.ToLower(logConfig.File.Format) == "colourful" { return createConsoleWriter(lumberjackLogger, level, logConfig.File.Format), nil } else { return createJsonWriter(lumberjackLogger, level), nil @@ -97,7 +97,7 @@ func createConsoleLogger(logConfig Config) (*FilteredLevelWriter, error) { if err != nil { return nil, err } - if strings.ToLower(logConfig.Console.Format) == "text" || strings.ToLower(logConfig.Console.Format) == "colorful" { + if strings.ToLower(logConfig.Console.Format) == "text" || strings.ToLower(logConfig.Console.Format) == "colourful" { return createConsoleWriter(os.Stdout, level, logConfig.Console.Format), nil } else { return createJsonWriter(os.Stdout, level), nil diff --git a/internal/common/logging/config.go b/internal/common/logging/config.go index c8f844318df..db4c6987439 100644 --- a/internal/common/logging/config.go +++ b/internal/common/logging/config.go @@ -1,17 +1,16 @@ package logging import ( - "strings" - "github.com/pkg/errors" - "go.uber.org/zap/zapcore" + "github.com/rs/zerolog" "golang.org/x/exp/maps" + "strings" ) var validLogFormats = map[string]bool{ - "text": true, - "json": true, - "colorful": true, + "text": true, + "json": true, + "colourful": true, } // Config defines Armada logging configuration. @@ -50,7 +49,7 @@ type Config struct { } func validate(c Config) error { - _, err := parseLogLevel(c.Console.Level) + _, err := zerolog.ParseLevel(c.Console.Level) if err != nil { return err } @@ -61,7 +60,7 @@ func validate(c Config) error { } if c.File.Enabled { - _, err := parseLogLevel(c.File.Level) + _, err := zerolog.ParseLevel(c.File.Level) if err != nil { return err } @@ -91,27 +90,12 @@ func validate(c Config) error { func validateLogFormat(f string) error { _, ok := validLogFormats[f] if !ok { - err := errors.Errorf("unknown log format: %s. Valid formats are %s", f, maps.Keys(validLogFormats)) + err := errors.Errorf( + "unknown log format: %s. Valid formats are %s", + f, + strings.Join(maps.Keys(validLogFormats), ","), + ) return err } return nil } - -func parseLogLevel(level string) (zapcore.Level, error) { - switch strings.ToLower(level) { - case "debug": - return zapcore.DebugLevel, nil - case "info": - return zapcore.InfoLevel, nil - case "warn", "warning": - return zapcore.WarnLevel, nil - case "error": - return zapcore.ErrorLevel, nil - case "panic": - return zapcore.PanicLevel, nil - case "fatal": - return zapcore.FatalLevel, nil - default: - return zapcore.InfoLevel, errors.Errorf("unknown level: %s", level) - } -}