Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Changelog

All notable changes to this project will be documented in this file.

## 4.79.0 - TBD

### Fixed

- Setting the logging level to `TRACE`, `ALL`, `OFF` and `NONE` no longer emits an error. (@mihaitodor)

## 4.78.0 - 2026-01-16

### Added
Expand Down
22 changes: 14 additions & 8 deletions internal/cli/enterprise.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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?

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

}

rpMgr.SetTopicLoggerLevel(&logsLevel)
rpMgr.SetTopicLoggerLevel(logsLevel)

// Chroot if needed
if chrootPath != "" {
Expand Down
6 changes: 3 additions & 3 deletions internal/impl/kafka/enterprise/global_redpanda_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ func newTopicLogger(id string) *topicLogger {
return t
}

func (l *topicLogger) InitWithOutput(pipelineID, topic string, logsLevel slog.Level, o *service.OwnedOutput) {
func (l *topicLogger) InitWithOutput(pipelineID, topic string, logsLevel *slog.Level, o *service.OwnedOutput) {
l.pipelineID.Store(&pipelineID)
l.topic.Store(&topic)
l.level.Store(&logsLevel)
l.level.Store(logsLevel)
l.o.Store(o)
}

// Enabled returns true if the logger is enabled and false otherwise.
func (l *topicLogger) Enabled(_ context.Context, atLevel slog.Level) bool {
lvl := l.level.Load()
if lvl == nil {
return true
return false
}
return atLevel >= *lvl
}
Expand Down
21 changes: 13 additions & 8 deletions internal/impl/kafka/enterprise/global_redpanda_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (l *GlobalRedpandaManager) InitWithCustomDetails(pipelineID, logsTopic, sta
}

l.oCustom = tmpO
l.topicLogger.InitWithOutput(pipelineID, logsTopic, defaultLevel, l.oCustom)
l.topicLogger.InitWithOutput(pipelineID, logsTopic, &defaultLevel, l.oCustom)
l.statusEmitter.InitWithOutput(pipelineID, statusTopic, l.fallbackLogger, l.oCustom)

return nil
Expand Down Expand Up @@ -173,16 +173,21 @@ func (l *GlobalRedpandaManager) InitFromParsedConfig(pConf *service.ParsedConfig
return 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:
return fmt.Errorf("log level not recognized: %v", logsLevelStr)
}
Expand Down