|
|
@@ -7,8 +7,21 @@ import (
|
|
|
"k8s.io/klog"
|
|
|
)
|
|
|
|
|
|
+var seen = make(map[string]int)
|
|
|
+
|
|
|
+const logTypeLimit = 5
|
|
|
+
|
|
|
func Errorf(format string, a ...interface{}) {
|
|
|
- klog.Errorf(fmt.Sprintf("[Error] %s", format), a...)
|
|
|
+ timesLogged, ok := seen[format]
|
|
|
+ if !ok {
|
|
|
+ seen[format] = 1
|
|
|
+ } else if timesLogged > logTypeLimit {
|
|
|
+ f := fmt.Sprintf("[Error] %s", format)
|
|
|
+ klog.Errorf("%s seen more than %d times, suppressing future logs", f, logTypeLimit)
|
|
|
+ } else {
|
|
|
+ seen[format] += 1
|
|
|
+ klog.Errorf(fmt.Sprintf("[Error] %s", format), a...)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func Warningf(format string, a ...interface{}) {
|