fix(logger): preserve log file across commands#173
Conversation
Remove the os.Truncate call that was clearing the log file on every CLI invocation. The logger already opens files with O_APPEND and has a rotation mechanism (keeps last 500 lines at 1000-line limit), making truncation redundant and harmful for multi-command debugging sessions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @pbrissaud's task in 1m 11s —— View job PR Review: fix(logger): preserve log file across commands
SummaryThis is a clean and correct fix. The removed Why the change is correctThe logger in file, err := os.OpenFile(opts.FilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)It also has a built-in rotation mechanism ( Removing the No issues with this PRThe change is minimal, safe, and well-reasoned. Both deletions are justified. Unrelated pre-existing observation (not blocking)There is a subtle bug in the rotation logic in Verdict: LGTM ✓ — straightforward fix, no issues introduced. |
…loss After rewriteFile executed os.Rename(tempFile, l.filePath), the file handle stored in l.outputs pointed to the orphaned inode (unlinked from the filesystem path). All subsequent writes after a rotation would go to that orphaned inode and never appear in the log file. Fix by storing the *os.File reference on the Logger struct and rewriting in-place (Seek + Truncate + write) instead of temp-file rename, so the open handle in l.outputs always remains valid. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @pbrissaud's task in 1m 24s —— View job PR Review: fix(logger): preserve log file across commands
SummaryThis PR addresses two bugs across two commits: the original startup truncation fix and a follow-up fix for stale file handles after log rotation. Both are correct and well-reasoned. Commit 1 —
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
os.Truncatecall inPersistentPreRunthat was wiping the log file on every CLI invocationfmtimportO_APPENDand rotates at 1000 lines, making truncation redundantTest plan
task buildpasses--debugand verify both runs appear inkubeasy-cli.log🤖 Generated with Claude Code