From 5deb0375b928d21265e2818d1b58923552ba1c71 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 10 Feb 2022 18:22:35 +0100 Subject: [PATCH] fix new *lnDepth functions https://github.com/kubernetes/klog/pull/280 added several new functions and didn't quite get the print vs println difference right: the corresponding non-Depth functions use fmt.Println and the Depth versions should do the same. --- klog.go | 8 ++++---- test/output.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/klog.go b/klog.go index 96086a42..26c532b5 100644 --- a/klog.go +++ b/klog.go @@ -1615,7 +1615,7 @@ func Warningln(args ...interface{}) { // WarninglnDepth acts as Warningln but uses depth to determine which call frame to log. // WarninglnDepth(0, "msg") is the same as Warningln("msg"). func WarninglnDepth(depth int, args ...interface{}) { - logging.printDepth(warningLog, logging.logr, logging.filter, depth, args...) + logging.printlnDepth(warningLog, logging.logr, logging.filter, depth, args...) } // Warningf logs to the WARNING and INFO logs. @@ -1651,7 +1651,7 @@ func Errorln(args ...interface{}) { // ErrorlnDepth acts as Errorln but uses depth to determine which call frame to log. // ErrorlnDepth(0, "msg") is the same as Errorln("msg"). func ErrorlnDepth(depth int, args ...interface{}) { - logging.printDepth(errorLog, logging.logr, logging.filter, depth, args...) + logging.printlnDepth(errorLog, logging.logr, logging.filter, depth, args...) } // Errorf logs to the ERROR, WARNING, and INFO logs. @@ -1708,7 +1708,7 @@ func Fatalln(args ...interface{}) { // FatallnDepth acts as Fatalln but uses depth to determine which call frame to log. // FatallnDepth(0, "msg") is the same as Fatalln("msg"). func FatallnDepth(depth int, args ...interface{}) { - logging.printDepth(fatalLog, logging.logr, logging.filter, depth, args...) + logging.printlnDepth(fatalLog, logging.logr, logging.filter, depth, args...) } // Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, @@ -1752,7 +1752,7 @@ func Exitln(args ...interface{}) { // ExitlnDepth(0, "msg") is the same as Exitln("msg"). func ExitlnDepth(depth int, args ...interface{}) { atomic.StoreUint32(&fatalNoStacks, 1) - logging.printDepth(fatalLog, logging.logr, logging.filter, depth, args...) + logging.printlnDepth(fatalLog, logging.logr, logging.filter, depth, args...) } // Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). diff --git a/test/output.go b/test/output.go index 0448bea2..a4174914 100644 --- a/test/output.go +++ b/test/output.go @@ -499,7 +499,7 @@ I output.go:] "test" firstKey=1 secondKey=3 { name: "WarninglnDepth", logFunc: func() { klog.WarninglnDepth(0, "hello", "world") }, - output: "W output.go:] helloworld\n", // BUG + output: "W output.go:] hello world\n", }, { name: "Warningf", @@ -529,7 +529,7 @@ I output.go:] "test" firstKey=1 secondKey=3 { name: "ErrorlnDepth", logFunc: func() { klog.ErrorlnDepth(0, "hello", "world") }, - output: "E output.go:] helloworld\n", // BUG + output: "E output.go:] hello world\n", }, { name: "Errorf",