Introduce slog for structured daemon logging (bd-u2sc.4)

- Replace custom daemonLogger with slog-based structured logging
- Add --log-level flag (debug, info, warn, error) with default "info"
- Add --log-json flag for JSON-formatted log output
- Update log calls to use appropriate levels (Error, Warn, Info, Debug)
- Add test helper functions (newTestLogger, newTestLoggerWithWriter)

Log output examples:
  Text: time=2025-12-23T12:30:00Z level=INFO msg="daemon started" socket=/tmp/bd.sock
  JSON: {"time":"...","level":"INFO","msg":"daemon started","socket":"/tmp/bd.sock"}

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-23 13:43:40 -08:00
parent d834e4f4d8
commit 05f37d2408
10 changed files with 237 additions and 160 deletions

View File

@@ -65,11 +65,7 @@ func TestExportUpdatesDatabaseMtime(t *testing.T) {
}
// Update metadata after export (bd-ymj fix)
mockLogger := daemonLogger{
logFunc: func(format string, args ...interface{}) {
t.Logf(format, args...)
},
}
mockLogger := newTestLogger()
updateExportMetadata(ctx, store, jsonlPath, mockLogger, "")
// Get JSONL mtime
@@ -170,11 +166,7 @@ func TestDaemonExportScenario(t *testing.T) {
}
// Daemon updates metadata after export (bd-ymj fix)
mockLogger := daemonLogger{
logFunc: func(format string, args ...interface{}) {
t.Logf(format, args...)
},
}
mockLogger := newTestLogger()
updateExportMetadata(ctx, store, jsonlPath, mockLogger, "")
// THIS IS THE FIX: daemon now calls TouchDatabaseFile after export
@@ -249,11 +241,7 @@ func TestMultipleExportCycles(t *testing.T) {
}
// Update metadata after export (bd-ymj fix)
mockLogger := daemonLogger{
logFunc: func(format string, args ...interface{}) {
t.Logf(format, args...)
},
}
mockLogger := newTestLogger()
updateExportMetadata(ctx, store, jsonlPath, mockLogger, "")
// Apply fix