fix: accept log levels supported by older zot versions, validate configured log level#3639
Conversation
…igured log level 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>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3639 +/- ##
=======================================
Coverage 91.49% 91.50%
=======================================
Files 186 186
Lines 26281 26286 +5
=======================================
+ Hits 24047 24053 +6
+ Misses 1445 1444 -1
Partials 789 789 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR enhances log level handling to maintain backward compatibility with older zot versions that used zerolog. It adds support for additional log levels ("trace", "fatal", "panic") and improves error handling by validating log levels before logger creation.
Key Changes:
- Adds support for "trace", "fatal", and "panic" log levels to match zerolog's supported levels
- Makes ParseLevel function public for external validation
- Adds early validation in configuration loading to provide clear error messages instead of panics
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/log/log.go | Adds new log level aliases (trace→debug, fatal/panic→error), makes ParseLevel public, and improves error messages with list of supported levels |
| pkg/cli/server/root.go | Adds log level validation before logger creation to prevent panics and provide better error messages |
| pkg/cli/server/root_test.go | Adds tests for invalid log level validation and the new "trace" log level support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Accept the same log levels as in https://github.com/rs/zerolog/blob/5391dd7c34c86c2a3b731cd3c3f1b252706e7925/globals.go#L37
This is to maintain backward compatibility with older configurations.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.