From 8b904b149306eabd9487cd656bebcc47d1036cc8 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 29 Oct 2020 15:22:29 -0700 Subject: [PATCH] types/logger: fix LogOnChange to pass through format/args to underlying logger So they don't get interpretted as a format pattern or get rate-limited away in the wrong way. --- types/logger/logger.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/logger/logger.go b/types/logger/logger.go index c4c11c151..520280a4d 100644 --- a/types/logger/logger.go +++ b/types/logger/logger.go @@ -158,7 +158,10 @@ func LogOnChange(logf Logf, maxInterval time.Duration, timeNow func() time.Time) tLastLogged = timeNow() mu.Unlock() - logf(s) + // Re-stringify it (instead of using "%s", s) so something like "%s" + // doesn't end up getting rate-limited. (And can't use 's' as the pattern, + // as it might contain formatting directives.) + logf(format, args...) } }