Selaa lähdekoodia

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.
Brad Fitzpatrick 5 vuotta sitten
vanhempi
sitoutus
8b904b1493
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      types/logger/logger.go

+ 4 - 1
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...)
 	}
 
 }