Skip to content

Commit

Permalink
structured-logging: enable KobjSlice usage and warn Kobjs usage
Browse files Browse the repository at this point in the history
  • Loading branch information
harshanarayana committed Aug 31, 2022
1 parent f68289b commit 76fb3f2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion logcheck/pkg/logcheck.go
Expand Up @@ -314,7 +314,7 @@ func isContextualCall(fName string) bool {
"FlushLogger",
"FromContext",
"KObj",
"KObjs",
"KObjSlice",
"KRef",
"LoggerWithName",
"LoggerWithValues",
Expand Down
5 changes: 5 additions & 0 deletions logcheck/testdata/src/k8s.io/klog/v2/klog.go
Expand Up @@ -221,6 +221,11 @@ func KObjs(obj interface{}) interface{} {
return nil
}

// KObjSlice emulatess klog.KObjSlice
func KObjSlice(obj interface{}) interface{} {
return nil
}

func KRef(namespace, name string) interface{} {
return nil
}
Expand Down
Expand Up @@ -29,4 +29,5 @@ func doNotAlllowKlog() {
klog.InfoS("test log") // want `function "InfoS" should not be used, convert to contextual logging`
klog.ErrorS(nil, "test log") // want `function "ErrorS" should not be used, convert to contextual logging`
klog.V(1).Infof("test log") // want `function "V" should not be used, convert to contextual logging` `function "Infof" should not be used, convert to contextual logging`
klog.KObjs(nil) // want `function "KObjs" should not be used, convert to contextual logging`
}
Expand Up @@ -27,7 +27,7 @@ import (

func allowKlog() {
klog.KObj(nil)
klog.KObjs(nil)
klog.KObjSlice(nil)
klog.KRef("", "")
klog.FromContext(nil)
klog.TODO()
Expand Down

0 comments on commit 76fb3f2

Please sign in to comment.