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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user