diff --git a/klog.go b/klog.go index f04b85d4..c0080c0b 100644 --- a/klog.go +++ b/klog.go @@ -825,6 +825,8 @@ func kvListFormat(b *bytes.Buffer, keysAndValues ...interface{}) { switch v.(type) { case string, error: b.WriteString(fmt.Sprintf("%s=%q", k, v)) + case []byte: + b.WriteString(fmt.Sprintf("%s=%+q", k, v)) default: if _, ok := v.(fmt.Stringer); ok { b.WriteString(fmt.Sprintf("%s=%q", k, v)) diff --git a/klog_test.go b/klog_test.go index b7f01238..c0370c78 100644 --- a/klog_test.go +++ b/klog_test.go @@ -1067,6 +1067,14 @@ func TestKvListFormat(t *testing.T) { keysValues: []interface{}{"pod", "kubedns", "values", []string{"deployment", "svc", "configmap"}}, want: " pod=\"kubedns\" values=[deployment svc configmap]", }, + { + keysValues: []interface{}{"pod", "kubedns", "bytes", []byte("test case for byte array")}, + want: " pod=\"kubedns\" bytes=\"test case for byte array\"", + }, + { + keysValues: []interface{}{"pod", "kubedns", "bytes", []byte("��=� ⌘")}, + want: " pod=\"kubedns\" bytes=\"\\ufffd\\ufffd=\\ufffd \\u2318\"", + }, { keysValues: []interface{}{"pod", "kubedns", "maps", map[string]int{"three": 4}}, want: " pod=\"kubedns\" maps=map[three:4]",