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

Function truncateBody

rest/request.go:919–935  ·  view source on GitHub ↗

truncateBody decides if the body should be truncated, based on the glog Verbosity.

(body string)

Source from the content-addressed store, hash-verified

917
918// truncateBody decides if the body should be truncated, based on the glog Verbosity.
919func truncateBody(body string) string {
920 max := 0
921 switch {
922 case bool(klog.V(10)):
923 return body
924 case bool(klog.V(9)):
925 max = 10240
926 case bool(klog.V(8)):
927 max = 1024
928 }
929
930 if len(body) <= max {
931 return body
932 }
933
934 return body[:max] + fmt.Sprintf(" [truncated %d chars]", len(body)-max)
935}
936
937// glogBody logs a body output that could be either JSON or protobuf. It explicitly guards against
938// allocating a new string for the body output unless necessary. Uses a simple heuristic to determine

Callers 2

glogBodyFunction · 0.85
TestTruncateBodyFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestTruncateBodyFunction · 0.68