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:
@@ -122,12 +122,8 @@ func TestCreateLocalSyncFunc(t *testing.T) {
|
||||
t.Fatalf("Failed to create issue: %v", err)
|
||||
}
|
||||
|
||||
// Create logger
|
||||
log := daemonLogger{
|
||||
logFunc: func(format string, args ...interface{}) {
|
||||
t.Logf(format, args...)
|
||||
},
|
||||
}
|
||||
// Create logger (test output via newTestLogger)
|
||||
log := newTestLogger()
|
||||
|
||||
// Create and run local sync function
|
||||
doSync := createLocalSyncFunc(ctx, testStore, log)
|
||||
@@ -193,11 +189,7 @@ func TestCreateLocalExportFunc(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
log := daemonLogger{
|
||||
logFunc: func(format string, args ...interface{}) {
|
||||
t.Logf(format, args...)
|
||||
},
|
||||
}
|
||||
log := newTestLogger()
|
||||
|
||||
doExport := createLocalExportFunc(ctx, testStore, log)
|
||||
doExport()
|
||||
@@ -258,11 +250,7 @@ func TestCreateLocalAutoImportFunc(t *testing.T) {
|
||||
t.Fatalf("Failed to write JSONL: %v", err)
|
||||
}
|
||||
|
||||
log := daemonLogger{
|
||||
logFunc: func(format string, args ...interface{}) {
|
||||
t.Logf(format, args...)
|
||||
},
|
||||
}
|
||||
log := newTestLogger()
|
||||
|
||||
doImport := createLocalAutoImportFunc(ctx, testStore, log)
|
||||
doImport()
|
||||
@@ -379,11 +367,7 @@ func TestLocalModeInNonGitDirectory(t *testing.T) {
|
||||
t.Fatalf("Failed to create issue: %v", err)
|
||||
}
|
||||
|
||||
log := daemonLogger{
|
||||
logFunc: func(format string, args ...interface{}) {
|
||||
t.Logf(format, args...)
|
||||
},
|
||||
}
|
||||
log := newTestLogger()
|
||||
|
||||
// Run local sync (should work without git)
|
||||
doSync := createLocalSyncFunc(ctx, testStore, log)
|
||||
@@ -437,11 +421,7 @@ func TestLocalModeExportImportRoundTrip(t *testing.T) {
|
||||
defer func() { dbPath = oldDBPath }()
|
||||
dbPath = testDBPath
|
||||
|
||||
log := daemonLogger{
|
||||
logFunc: func(format string, args ...interface{}) {
|
||||
t.Logf(format, args...)
|
||||
},
|
||||
}
|
||||
log := newTestLogger()
|
||||
|
||||
// Create issues
|
||||
for i := 0; i < 5; i++ {
|
||||
|
||||
Reference in New Issue
Block a user