Merge pull request #108159 from pohly/logcheck

logcheck update and golangci-lint integration

Kubernetes-commit: d60df5ba044fdb1cf20e4fc6d2ba45337d322052
This commit is contained in:
Kubernetes Publisher 2022-03-24 18:37:50 -07:00
commit b307538aa1

View File

@ -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)))
}
}
}