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

@@ -3,10 +3,10 @@ package api
import (
"context"
"encoding/json"
"log"
"net/http"
"geniusrun/backend/internal/garmin"
applog "geniusrun/backend/internal/log"
)
// detailFillBatchSize bounds how many activities' details/splits are fetched
@@ -45,7 +45,7 @@ func (s *Server) recordAuthResult(ctx context.Context, userID int64, res garmin.
if res.Status == garmin.AuthSuccess {
if err := s.DB.MarkGarminConnected(ctx, userID); err != nil {
log.Printf("api: mark garmin connected for user %d: %v", userID, err)
applog.FromContext(ctx).Error("mark garmin connected", "user_id", userID, "error", err)
}
}
}