From 14179dce0733ca1eb62367e5199523d0484eee14 Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Fri, 15 Sep 2023 09:42:36 -0300 Subject: [PATCH] Avoid slog abuse :) 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. --- mocks/storeserver/storemockserver/storemockserver.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mocks/storeserver/storemockserver/storemockserver.go b/mocks/storeserver/storemockserver/storemockserver.go index e446153c2..0c9a4a35c 100644 --- a/mocks/storeserver/storemockserver/storemockserver.go +++ b/mocks/storeserver/storemockserver/storemockserver.go @@ -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 } @@ -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 }