-
Notifications
You must be signed in to change notification settings - Fork 913
Fix TRACE, ALL, OFF and NONE log levels #3922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -110,21 +110,27 @@ func InitEnterpriseCLI(binaryName, version, dateBuilt string, schema *service.Co | |||||
| fbLogger.Errorf("Failed reading log level from config: %v", err) | ||||||
| } | ||||||
|
|
||||||
| var logsLevel slog.Level | ||||||
| levelPtr := func(level slog.Level) *slog.Level { | ||||||
| return &level | ||||||
| } | ||||||
| var logsLevel *slog.Level | ||||||
| switch strings.ToLower(logsLevelStr) { | ||||||
| case "debug": | ||||||
| logsLevel = slog.LevelDebug | ||||||
| case "debug", "trace", "all": | ||||||
| logsLevel = levelPtr(slog.LevelDebug) | ||||||
| case "info": | ||||||
| logsLevel = slog.LevelInfo | ||||||
| logsLevel = levelPtr(slog.LevelInfo) | ||||||
| case "warn": | ||||||
| logsLevel = slog.LevelWarn | ||||||
| case "error": | ||||||
| logsLevel = slog.LevelError | ||||||
| logsLevel = levelPtr(slog.LevelWarn) | ||||||
| case "error", "fatal": | ||||||
| logsLevel = levelPtr(slog.LevelError) | ||||||
| case "off", "none": | ||||||
| // Logging disabled | ||||||
| default: | ||||||
| logsLevel = levelPtr(slog.LevelInfo) | ||||||
| fbLogger.Errorf("Log level '%s' not recognized, using to default level %s", logsLevelStr, logsLevel) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable, so the behaviour remains the same?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should, yeah |
||||||
| } | ||||||
|
|
||||||
| rpMgr.SetTopicLoggerLevel(&logsLevel) | ||||||
| rpMgr.SetTopicLoggerLevel(logsLevel) | ||||||
|
|
||||||
| // Chroot if needed | ||||||
| if chrootPath != "" { | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought(non-blocker): Is it worth changing this error whilst we're at it? I presume it's meant to read "using the default level".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call-out, thank you! I looked through the code again and I think it's better now.
I also realised that
topicLogger.Enabled()returnedtruewhenlevel == nil, but I don't think that ever happened in the original code because it was passed by value. I could be wrong, but I think this should returnfalsewhen users set the log level toOFF/NONE, so I updated it. WDYT?