Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions internal/httputil/logging.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package httputil

import (
"fmt"
"net/http"

"github.com/block/cachew/internal/logging"
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion internal/strategy/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down