mirror of
https://github.com/project-zot/zot.git
synced 2026-06-19 05:57:57 +08:00
fix: accept log levels supported by older zot versions, validate configured log level (#3639)
In zot config accept the same log levels as in https://github.com/rs/zerolog/blob/5391dd7c34c86c2a3b731cd3c3f1b252706e7925/globals.go#L37 This is to maintain backward compatibility with other zot version configurations. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
@@ -1068,6 +1068,13 @@ func LoadConfiguration(config *config.Config, configPath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Validate log level before creating logger to avoid panic
|
||||
if _, err := zlog.ParseLevel(config.Log.Level); err != nil {
|
||||
logger.Error().Err(zerr.ErrBadConfig).Str("level", config.Log.Level).Msg(err.Error())
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
log := zlog.NewLogger(config.Log.Level, config.Log.Output)
|
||||
|
||||
if len(metaData.Keys) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user