-
Notifications
You must be signed in to change notification settings - Fork 257
Open
Labels
automatedIssues created by cagentIssues created by cagentkind/bugSomething isn't workingSomething isn't working
Description
🟡 medium - bug
File: cmd/root/root.go (line 191)
Code
logFile, err := logging.NewRotatingFile(path)
if err != nil {
return err
}
f.logFile = logFile
slog.SetDefault(slog.New(slog.NewTextHandler(logFile, &slog.HandlerOptions{Level: slog.LevelDebug})))Problem
In setupLogging, if logging.NewRotatingFile(path) returns an error, the error is returned, but slog.SetDefault is never updated to write to the file. This means that if debug mode is enabled and an error occurs during log file creation, all subsequent debug logs will be silently discarded because the default logger remains slog.DiscardHandler from line 186.
Suggested Fix
If logging.NewRotatingFile returns an error, slog.SetDefault should be configured to write to cmd.ErrOrStderr() with debug level, similar to how it's handled in PersistentPreRunE for the initial logging setup. This ensures that debug logs are still visible even if file logging cannot be established.
Found by nightly codebase scan
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
automatedIssues created by cagentIssues created by cagentkind/bugSomething isn't workingSomething isn't working