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:
@@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -11,6 +10,7 @@ import (
|
||||
|
||||
"geniusrun/backend/internal/auth"
|
||||
"geniusrun/backend/internal/garmin"
|
||||
applog "geniusrun/backend/internal/log"
|
||||
)
|
||||
|
||||
// setupSessionIdleTimeout bounds how long an onboarding Garmin session
|
||||
@@ -196,7 +196,7 @@ func (s *Server) handleSetupComplete(w http.ResponseWriter, r *http.Request) {
|
||||
oldDir := setupTokenStoreDir(s.ClientConfig.TokenStorePath, claims.Sub)
|
||||
newDir := filepath.Join(s.ClientConfig.TokenStorePath, strconv.FormatInt(userID, 10))
|
||||
if err := os.Rename(oldDir, newDir); err != nil && !os.IsNotExist(err) {
|
||||
log.Printf("api: rename setup token store dir for user %d: %v", userID, err)
|
||||
applog.FromContext(r.Context()).Error("rename setup token store dir", "user_id", userID, "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user