Return early from eviction debug helpers if !glog.V(3)

Should keep us from running a bunch of loops needlessly.
pull/6/head
Eric Paris 2017-03-08 20:19:52 -05:00
parent 98ae572225
commit df590da6ab
1 changed files with 10 additions and 4 deletions

View File

@ -739,24 +739,30 @@ func thresholdsMet(thresholds []evictionapi.Threshold, observations signalObserv
} }
func debugLogObservations(logPrefix string, observations signalObservations) { func debugLogObservations(logPrefix string, observations signalObservations) {
if !glog.V(3) {
return
}
for k, v := range observations { for k, v := range observations {
if !v.time.IsZero() { if !v.time.IsZero() {
glog.V(3).Infof("eviction manager: %v: signal=%v, available: %v, capacity: %v, time: %v", logPrefix, k, v.available, v.capacity, v.time) glog.Infof("eviction manager: %v: signal=%v, available: %v, capacity: %v, time: %v", logPrefix, k, v.available, v.capacity, v.time)
} else { } else {
glog.V(3).Infof("eviction manager: %v: signal=%v, available: %v, capacity: %v", logPrefix, k, v.available, v.capacity) glog.Infof("eviction manager: %v: signal=%v, available: %v, capacity: %v", logPrefix, k, v.available, v.capacity)
} }
} }
} }
func debugLogThresholdsWithObservation(logPrefix string, thresholds []evictionapi.Threshold, observations signalObservations) { func debugLogThresholdsWithObservation(logPrefix string, thresholds []evictionapi.Threshold, observations signalObservations) {
if !glog.V(3) {
return
}
for i := range thresholds { for i := range thresholds {
threshold := thresholds[i] threshold := thresholds[i]
observed, found := observations[threshold.Signal] observed, found := observations[threshold.Signal]
if found { if found {
quantity := evictionapi.GetThresholdQuantity(threshold.Value, observed.capacity) quantity := evictionapi.GetThresholdQuantity(threshold.Value, observed.capacity)
glog.V(3).Infof("eviction manager: %v: threshold [signal=%v, quantity=%v] observed %v", logPrefix, threshold.Signal, quantity, observed.available) glog.Infof("eviction manager: %v: threshold [signal=%v, quantity=%v] observed %v", logPrefix, threshold.Signal, quantity, observed.available)
} else { } else {
glog.V(3).Infof("eviction manager: %v: threshold [signal=%v] had no observation", logPrefix, threshold.Signal) glog.Infof("eviction manager: %v: threshold [signal=%v] had no observation", logPrefix, threshold.Signal)
} }
} }
} }