diff --git a/logcheck/main.go b/logcheck/main.go index f82f6ea..ffafecd 100644 --- a/logcheck/main.go +++ b/logcheck/main.go @@ -129,6 +129,7 @@ func isUnstructured(fName string) bool { "Warning", "Warningf", "Warningln", "WarningDepth", "Error", "Errorf", "Errorln", "ErrorDepth", "Fatal", "Fatalf", "Fatalln", "FatalDepth", + "Exit", "Exitf", "Exitln", "ExitDepth", } for _, name := range unstrucured { diff --git a/logcheck/testdata/src/allowUnstructuredLogs/allowUnstructuredLogs.go b/logcheck/testdata/src/allowUnstructuredLogs/allowUnstructuredLogs.go index 346410d..879e5cf 100644 --- a/logcheck/testdata/src/allowUnstructuredLogs/allowUnstructuredLogs.go +++ b/logcheck/testdata/src/allowUnstructuredLogs/allowUnstructuredLogs.go @@ -60,4 +60,8 @@ func allowUnstructuredLogs() { klog.Fatalf("test log") klog.Fatalln("test log") klog.FatalDepth(1, "test log") + klog.Exit("test log") + klog.ExitDepth(1, "test log") + klog.Exitln("test log") + klog.Exitf("test log") } diff --git a/logcheck/testdata/src/doNotAllowUnstructuredLogs/doNotAllowUnstructuredLogs.go b/logcheck/testdata/src/doNotAllowUnstructuredLogs/doNotAllowUnstructuredLogs.go index 19c254a..f4a6eeb 100644 --- a/logcheck/testdata/src/doNotAllowUnstructuredLogs/doNotAllowUnstructuredLogs.go +++ b/logcheck/testdata/src/doNotAllowUnstructuredLogs/doNotAllowUnstructuredLogs.go @@ -60,5 +60,8 @@ func doNotAllowUnstructuredLogs() { klog.Fatalf("test log") // want `unstructured logging function "Fatalf" should not be used` klog.Fatalln("test log") // want `unstructured logging function "Fatalln" should not be used` klog.FatalDepth(1, "test log") // want `unstructured logging function "FatalDepth" should not be used` - + klog.Exit("test log") // want `unstructured logging function "Exit" should not be used` + klog.Exitf("test log") // want `unstructured logging function "Exitf" should not be used` + klog.Exitln("test log") // want `unstructured logging function "Exitln" should not be used` + klog.ExitDepth(1, "test log") // want `unstructured logging function "ExitDepth" should not be used` } diff --git a/logcheck/testdata/src/k8s.io/klog/v2/klog.go b/logcheck/testdata/src/k8s.io/klog/v2/klog.go index 63bfafe..c43ee16 100644 --- a/logcheck/testdata/src/k8s.io/klog/v2/klog.go +++ b/logcheck/testdata/src/k8s.io/klog/v2/klog.go @@ -180,3 +180,20 @@ func Fatalln(args ...interface{}) { // Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. func Fatalf(format string, args ...interface{}) { } + +func Exit(args ...interface{}) { +} + +// ExitDepth acts as Exit but uses depth to determine which call frame to log. +// ExitDepth(0, "msg") is the same as Exit("msg"). +func ExitDepth(depth int, args ...interface{}) { +} + +// Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). +func Exitln(args ...interface{}) { +} + +// Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Exitf(format string, args ...interface{}) { +}