diff --git a/internal/httputil/logging.go b/internal/httputil/logging.go index 8eeae13..aad2d1e 100644 --- a/internal/httputil/logging.go +++ b/internal/httputil/logging.go @@ -1,7 +1,6 @@ package httputil import ( - "fmt" "net/http" "github.com/block/cachew/internal/logging" @@ -10,7 +9,7 @@ import ( func LoggingMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Propagate attributes tot the handlers. - logger := logging.FromContext(r.Context()).With("request", fmt.Sprintf("%s %s", r.Method, r.RequestURI)) + logger := logging.FromContext(r.Context()).With("method", r.Method, "uri", r.RequestURI) r = r.WithContext(logging.ContextWithLogger(r.Context(), logger)) logger.Debug("Request received") next.ServeHTTP(w, r) diff --git a/internal/strategy/git/git.go b/internal/strategy/git/git.go index 11b3cc5..c153d67 100644 --- a/internal/strategy/git/git.go +++ b/internal/strategy/git/git.go @@ -581,7 +581,8 @@ func (s *Strategy) doFetch(ctx context.Context, repo *gitclone.Repository) error start := time.Now() if err := repo.Fetch(ctx); err != nil { - return errors.Errorf("fetch failed in %s: %w", time.Since(start), err) + logger.ErrorContext(ctx, "Fetch failed", "upstream", repo.UpstreamURL(), "duration", time.Since(start), "error", err) + return errors.Errorf("fetch failed: %w", err) } logger.InfoContext(ctx, "Fetch completed", "upstream", repo.UpstreamURL(), "duration", time.Since(start)) return nil