Skip to content

Commit

Permalink
Merge pull request #157 from yuzhiquan/bug-infoS-timeformat
Browse files Browse the repository at this point in the history
fix imported bug InfoS time encode format
  • Loading branch information
k8s-ci-robot committed Jun 3, 2020
2 parents 2359470 + 1ccc0e1 commit db7f626
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
12 changes: 9 additions & 3 deletions klog.go
Expand Up @@ -800,10 +800,16 @@ func kvListFormat(b *bytes.Buffer, keysAndValues ...interface{}) {
v = missingValue
}
b.WriteByte(' ')
if _, ok := v.(fmt.Stringer); ok {

switch v.(type) {
case string:
b.WriteString(fmt.Sprintf("%s=%q", k, v))
} else {
b.WriteString(fmt.Sprintf("%s=%#v", k, v))
default:
if _, ok := v.(fmt.Stringer); ok {
b.WriteString(fmt.Sprintf("%s=%q", k, v))
} else {
b.WriteString(fmt.Sprintf("%s=%+v", k, v))
}
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions klog_test.go
Expand Up @@ -849,20 +849,21 @@ func TestKvListFormat(t *testing.T) {
keysValues: []interface{}{"pod", "kubedns", "spec", struct {
X int
Y string
}{X: 76, Y: "strval"}},
want: " pod=\"kubedns\" spec=struct { X int; Y string }{X:76, Y:\"strval\"}",
N time.Time
}{X: 76, Y: "strval", N: time.Date(2006, 1, 2, 15, 4, 5, .067890e9, time.UTC)}},
want: " pod=\"kubedns\" spec={X:76 Y:strval N:2006-01-02 15:04:05.06789 +0000 UTC}",
},
{
keysValues: []interface{}{"pod", "kubedns", "values", []int{8, 6, 7, 5, 3, 0, 9}},
want: " pod=\"kubedns\" values=[]int{8, 6, 7, 5, 3, 0, 9}",
want: " pod=\"kubedns\" values=[8 6 7 5 3 0 9]",
},
{
keysValues: []interface{}{"pod", "kubedns", "values", []string{"deployment", "svc", "configmap"}},
want: " pod=\"kubedns\" values=[]string{\"deployment\", \"svc\", \"configmap\"}",
want: " pod=\"kubedns\" values=[deployment svc configmap]",
},
{
keysValues: []interface{}{"pod", "kubedns", "maps", map[string]int{"three": 4}},
want: " pod=\"kubedns\" maps=map[string]int{\"three\":4}",
want: " pod=\"kubedns\" maps=map[three:4]",
},
{
keysValues: []interface{}{"pod", KRef("kube-system", "kubedns"), "status", "ready"},
Expand Down

0 comments on commit db7f626

Please sign in to comment.