MCPcopy
hub / github.com/kubernetes/client-go / glogBody

Function glogBody

rest/request.go:940–950  ·  view source on GitHub ↗

glogBody logs a body output that could be either JSON or protobuf. It explicitly guards against allocating a new string for the body output unless necessary. Uses a simple heuristic to determine whether the body is printable.

(prefix string, body []byte)

Source from the content-addressed store, hash-verified

938// allocating a new string for the body output unless necessary. Uses a simple heuristic to determine
939// whether the body is printable.
940func glogBody(prefix string, body []byte) {
941 if klog.V(8) {
942 if bytes.IndexFunc(body, func(r rune) bool {
943 return r < 0x0a
944 }) != -1 {
945 klog.Infof("%s:\n%s", prefix, truncateBody(hex.Dump(body)))
946 } else {
947 klog.Infof("%s: %s", prefix, truncateBody(string(body)))
948 }
949 }
950}
951
952// maxUnstructuredResponseTextBytes is an upper bound on how much output to include in the unstructured error.
953const maxUnstructuredResponseTextBytes = 2048

Callers 3

BodyMethod · 0.85
DoRawMethod · 0.85
transformResponseMethod · 0.85

Calls 1

truncateBodyFunction · 0.85

Tested by

no test coverage detected