use log level configuration from database#28290
Open
tolot27 wants to merge 8 commits intoevcc-io:masterfrom
Open
use log level configuration from database#28290tolot27 wants to merge 8 commits intoevcc-io:masterfrom
tolot27 wants to merge 8 commits intoevcc-io:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The call to
parseLogLevelshas moved to only occur afterconfigureDatabasesucceeds, which means log level configuration will not be applied for database-related errors anymore; consider whether you want to preserve the previous behavior of having logging configured before attempting DB setup. - The
parseLogLevelsfunction now has side effects onviper(settinglevelandlevels) in addition to parsing; if this is intentional, consider updating the function name or adding a brief comment to make the mutating behavior explicit for future callers. - There is a commented-out
viper.Set("log", conf.Log)inconfigureEnvironment; please either remove it or document why it must remain commented to avoid confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The call to `parseLogLevels` has moved to only occur after `configureDatabase` succeeds, which means log level configuration will not be applied for database-related errors anymore; consider whether you want to preserve the previous behavior of having logging configured before attempting DB setup.
- The `parseLogLevels` function now has side effects on `viper` (setting `level` and `levels`) in addition to parsing; if this is intentional, consider updating the function name or adding a brief comment to make the mutating behavior explicit for future callers.
- There is a commented-out `viper.Set("log", conf.Log)` in `configureEnvironment`; please either remove it or document why it must remain commented to avoid confusion.
## Individual Comments
### Comment 1
<location path="cmd/setup.go" line_range="504-513" />
<code_context>
err := wrapErrorWithClass(ClassDatabase, configureDatabase(conf.Database))
+ // load persisted log levels and apply logging configuration
+ if err == nil {
+ if settings.Exists(keys.Levels) {
+ if err := migrateYamlToJson(keys.Levels, &conf.Levels); err != nil {
+ return err
+ }
+ }
+ if len(conf.Levels) > 0 {
+ viper.Set("levels", conf.Levels)
+ } else {
+ log.INFO.Printf("No log levels configured in database, using defaults from command line: %v", conf.Log)
+ //viper.Set("log", conf.Log)
+ }
+ parseLogLevels()
+ }
+
</code_context>
<issue_to_address>
**question (bug_risk):** Skipping `parseLogLevels` when `configureDatabase` fails might leave logging in an inconsistent state during error handling.
Because `parseLogLevels()` now runs only when `configureDatabase` succeeds, any error-handling paths that log database issues may run with whatever logging state existed before `configureEnvironment` (e.g., CLI defaults or none). If you want consistent logging even on DB setup failure, consider invoking `parseLogLevels()` regardless of `configureDatabase`’s result (possibly in a reduced form using only CLI/config values).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
naltatis
reviewed
Mar 17, 2026
naltatis
reviewed
Mar 17, 2026
naltatis
reviewed
Mar 17, 2026
naltatis
reviewed
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First part for #25763. The default log level can be specified using
"default"as key.What is missing: