Skip to content

Commit

Permalink
Avoid slog abuse :)
Browse files Browse the repository at this point in the history
Log messages must stay readable and complete.
Structured logging fields are for data analysis.
A human reading a log should not need to look into them
to completely understand what's being reported.
  • Loading branch information
CarlosNihelton committed Sep 15, 2023
1 parent c270db2 commit 14179dc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mocks/storeserver/storemockserver/storemockserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,13 @@ func (s *Server) handlePurchase(w http.ResponseWriter, r *http.Request) {
}

if id == ServerErrorValue {
slog.Info("server error triggered", "endpoint", PurchasePath, ProductIDParam, id)
slog.Info(fmt.Sprintf("%s: server error triggered. Product ID was: %s", PurchasePath, id))
fmt.Fprintf(w, `{%q:%q}`, PurchaseStatusKey, ServerErrorResult)
return
}

if id == CannotPurchaseValue {
slog.Info("purchase error triggered", "endpoint", PurchasePath, ProductIDParam, id)
slog.Info(fmt.Sprintf("%s: purchase error triggered. Product ID was: %s", PurchasePath, id))
fmt.Fprintf(w, `{%q:%q}`, PurchaseStatusKey, NotPurchasedResult)
return
}
Expand All @@ -264,7 +264,7 @@ func (s *Server) handlePurchase(w http.ResponseWriter, r *http.Request) {
}

if p.IsInUserCollection {
slog.Info("product already in user collection", "endpoint", PurchasePath, ProductIDParam, id)
slog.Info(fmt.Sprintf("%s: product %q already in user collection", PurchasePath, id))
fmt.Fprintf(w, `{%q:%q}`, PurchaseStatusKey, AlreadyPurchasedResult)
return
}
Expand Down

0 comments on commit 14179dc

Please sign in to comment.