-
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?
Conversation
85cb23f to
378556e
Compare
5d69134 to
7af9039
Compare
| case "off", "none": | ||
| // Logging disabled | ||
| default: | ||
| fbLogger.Errorf("Log level '%s' not recognized, using to default level %s", logsLevelStr, logsLevel) |
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() returned true when level == 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 return false when users set the log level to OFF / NONE, so I updated it. WDYT?
|
Thanks @mihaitodor! |
7af9039 to
6b37110
Compare
| // Logging disabled | ||
| default: | ||
| logsLevel = levelPtr(slog.LevelInfo) | ||
| fbLogger.Errorf("Log level '%s' not recognized, using to default level %s", logsLevelStr, logsLevel) |
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.
| fbLogger.Errorf("Log level '%s' not recognized, using to default level %s", logsLevelStr, logsLevel) | |
| fbLogger.Errorf("Log level '%s' not recognized, using the default level %s", logsLevelStr, logsLevel) |
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.
I also realised that topicLogger.Enabled() returned true when level == 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 return false when users set the log level to OFF / NONE, so I updated it. WDYT?
Sounds reasonable, so the behaviour remains the same?
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.
It should, yeah
Sending trace logs on the topic logger probably doesn't make much sense, so we fall back to DEBUG for it if TRACE is requested. Fixes redpanda-data#3872. Signed-off-by: Mihai Todor <todormihai@gmail.com>
6b37110 to
74fb70a
Compare
Sending trace logs on the topic logger probably doesn't make much sense, so we fall back to DEBUG for it if TRACE is requested.
Fixes #3872.
PS: I noticed that
benthos run --log.level=tracedoesn't error out. Guess the topic logger is only configured via theloggerconfig section, which might be a bit confusing...