fix(log): --stats --cmd audit now reads audit.log instead of operations.log

runLogStats() only checked the --audit flag to pick the log file,
ignoring filter.Cmd. This caused `log --stats --cmd audit` to read
operations.log and report "No log entries" even when audit data existed.

Align with runLog() by also checking f.Cmd == "audit".
This commit is contained in:
Willie
2026-02-26 21:43:21 +08:00
parent 2caa290a58
commit a5c83a7449
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -245,7 +245,7 @@ Examples:
func runLogStats(configPath string, auditOnly bool, f oplog.Filter) error {
filename := oplog.OpsFile
if auditOnly {
if auditOnly || f.Cmd == "audit" {
filename = oplog.AuditFile
}
+20
View File
@@ -464,6 +464,26 @@ targets:
result.AssertOutputContains(t, "OK:")
}
func TestLog_StatsCmdAuditReadsAuditLog(t *testing.T) {
sb := testutil.NewSandbox(t)
defer sb.Cleanup()
sb.CreateSkill("s1", map[string]string{"SKILL.md": "# S\n\nTest."})
tp := sb.CreateTarget("claude")
sb.WriteConfig(`source: ` + sb.SourcePath + `
targets:
claude:
path: ` + tp + `
`)
sb.RunCLI("audit")
result := sb.RunCLI("log", "--stats", "--cmd", "audit")
result.AssertSuccess(t)
result.AssertOutputContains(t, "audit")
result.AssertOutputContains(t, "OK:")
}
func TestLog_CheckCreatesEntry(t *testing.T) {
sb := testutil.NewSandbox(t)
defer sb.Cleanup()