From 802c30bae458cb66d594c88c2e6231cbf821a1b8 Mon Sep 17 00:00:00 2001 From: komuw Date: Sat, 17 Aug 2024 12:28:23 +0300 Subject: [PATCH] g --- config/example_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/example_test.go b/config/example_test.go index bceb0a0c..64327e1a 100644 --- a/config/example_test.go +++ b/config/example_test.go @@ -34,8 +34,12 @@ func ExampleNew() { config.SingleIpStrategy("CF-Connecting-IP"), // function to log in middlewares. func(_ http.ResponseWriter, r http.Request, statusCode int, fields []any) { - reqL := log.WithID(r.Context(), l) - reqL.Info("request-and-response", fields...) + if statusCode >= http.StatusInternalServerError { + // Only log 500's + reqL := log.WithID(r.Context(), l) + fields = append(fields, "statusCode", statusCode) + reqL.Info("request-and-response", fields...) + } }, // If a particular IP address sends more than 13 requests per second, throttle requests from that IP. 13.0,