diff --git a/rest/request.go b/rest/request.go index 86f51229e1..ef94353011 100644 --- a/rest/request.go +++ b/rest/request.go @@ -1051,13 +1051,13 @@ func truncateBody(body string) string { // allocating a new string for the body output unless necessary. Uses a simple heuristic to determine // whether the body is printable. func glogBody(prefix string, body []byte) { - if klog.V(8).Enabled() { + if klogV := klog.V(8); klogV.Enabled() { if bytes.IndexFunc(body, func(r rune) bool { return r < 0x0a }) != -1 { - klog.Infof("%s:\n%s", prefix, truncateBody(hex.Dump(body))) + klogV.Infof("%s:\n%s", prefix, truncateBody(hex.Dump(body))) } else { - klog.Infof("%s: %s", prefix, truncateBody(string(body))) + klogV.Infof("%s: %s", prefix, truncateBody(string(body))) } } }