refactor(log): replace stdlib log with the application JSON logger

Every log.Printf/Fatalf becomes a structured slog call through
internal/log: request handlers use the request-scoped logger
(applog.FromContext, carrying request_id), startup failures exit via a
fatal() helper that still emits JSON, and the seedsample/dumpschema CLIs
bootstrap the same JSON logger. Stale client_test expectations aligned
with the refactored wrapper-call logging (message casing, result attr,
ERROR level).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 16:33:26 +02:00
parent 042579a396
commit 431315bac3
13 changed files with 72 additions and 50 deletions

View File

@@ -10,11 +10,12 @@ package main
import (
"fmt"
"log"
"log/slog"
"os"
"path/filepath"
"strings"
applog "geniusrun/backend/internal/log"
"geniusrun/backend/internal/store"
)
@@ -26,6 +27,7 @@ type schemaEntry struct {
}
func main() {
slog.SetDefault(applog.NewLogger("info", os.Stdout))
tmpDir, err := os.MkdirTemp("", "geniusrun-dumpschema")
must(err)
defer os.RemoveAll(tmpDir)
@@ -91,11 +93,12 @@ func main() {
outPath := "../docs/DATABASE.md"
must(os.WriteFile(outPath, []byte(b.String()), 0644))
log.Printf("wrote %s", outPath)
slog.Info("wrote schema doc", "path", outPath)
}
func must(err error) {
if err != nil {
log.Fatal(err)
slog.Error("dumpschema", "error", err)
os.Exit(1)
}
}