Skip to content

Commit

Permalink
fix byte array display in InfoS and ErrorS
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhiquan committed May 10, 2021
1 parent 0cc9b83 commit 3efd469
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion klog.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func kvListFormat(b *bytes.Buffer, keysAndValues ...interface{}) {
b.WriteByte(' ')

switch v.(type) {
case string, error:
case string, error, []byte:
b.WriteString(fmt.Sprintf("%s=%q", k, v))
default:
if _, ok := v.(fmt.Stringer); ok {
Expand Down
4 changes: 4 additions & 0 deletions klog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,10 @@ 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", "[]byte", []byte("test for byte array")},
want: " pod=\"kubedns\" []byte=\"test for byte array\"",
},
{
keysValues: []interface{}{"pod", "kubedns", "maps", map[string]int{"three": 4}},
want: " pod=\"kubedns\" maps=map[three:4]",
Expand Down

0 comments on commit 3efd469

Please sign in to comment.