From 37d719d20cf8f5f117da2a18bb3a53fe0c90eb80 Mon Sep 17 00:00:00 2001 From: Nikhil Ranjan Date: Thu, 12 Sep 2019 13:35:07 +0200 Subject: [PATCH] Converting to structured logging the file app/ratelimit.go (#12176) --- app/ratelimit.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/ratelimit.go b/app/ratelimit.go index 0a7715f25b..8c560cbaaf 100644 --- a/app/ratelimit.go +++ b/app/ratelimit.go @@ -4,7 +4,6 @@ package app import ( - "fmt" "math" "net/http" "strconv" @@ -77,14 +76,14 @@ func (rl *RateLimiter) GenerateKey(r *http.Request) string { func (rl *RateLimiter) RateLimitWriter(key string, w http.ResponseWriter) bool { limited, context, err := rl.throttledRateLimiter.RateLimit(key, 1) if err != nil { - mlog.Critical("Internal server error when rate limiting. Rate Limiting broken. Error:" + err.Error()) + mlog.Critical("Internal server error when rate limiting. Rate Limiting broken.", mlog.Err(err)) return false } setRateLimitHeaders(w, context) if limited { - mlog.Error(fmt.Sprintf("Denied due to throttling settings code=429 key=%v", key)) + mlog.Error("Denied due to throttling settings code=429", mlog.String("key", key)) http.Error(w, "limit exceeded", 429) }