Skip to content

Conversation

@mihaitodor
Copy link
Contributor

@mihaitodor mihaitodor commented Jan 19, 2026

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=trace doesn't error out. Guess the topic logger is only configured via the logger config section, which might be a bit confusing...

@mihaitodor mihaitodor force-pushed the mihaitodor-fix-trace-log branch from 85cb23f to 378556e Compare January 19, 2026 22:46
@mihaitodor mihaitodor force-pushed the mihaitodor-fix-trace-log branch 2 times, most recently from 5d69134 to 7af9039 Compare January 19, 2026 23:16
@mihaitodor mihaitodor changed the title Fix TRACE log level Fix TRACE, ALL, OFF and NONE log levels Jan 19, 2026
case "off", "none":
// Logging disabled
default:
fbLogger.Errorf("Log level '%s' not recognized, using to default level %s", logsLevelStr, logsLevel)
Copy link
Contributor

@josephwoodward josephwoodward Jan 20, 2026

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".

Copy link
Contributor Author

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?

@josephwoodward
Copy link
Contributor

Thanks @mihaitodor!

@mihaitodor mihaitodor force-pushed the mihaitodor-fix-trace-log branch from 7af9039 to 6b37110 Compare January 20, 2026 21:32
// Logging disabled
default:
logsLevel = levelPtr(slog.LevelInfo)
fbLogger.Errorf("Log level '%s' not recognized, using to default level %s", logsLevelStr, logsLevel)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link
Contributor

@josephwoodward josephwoodward Jan 21, 2026

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?

Copy link
Contributor Author

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>
@mihaitodor mihaitodor force-pushed the mihaitodor-fix-trace-log branch from 6b37110 to 74fb70a Compare January 22, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logger: unexpected error log when using TRACE level

3 participants