Repository: kubernetes/klog (go)

Issue:
When error is nil, ErrorS change log level
/kind bug

**What steps did you take and what happened:**
[A clear and concise description of what the bug is.]

If err ==nil  will result in 
```
klog.Errors(nil, "xxxxxxxxx")
>>>
I0102 15:04:05.067890    1234 prober_manager.go:956] "xxxxxxxxxxxxxxxxxxx"
```
This would change log level, because [klog.go#L809](https://github.com/kubernetes/klog/blob/110d443dcd6b29c2941cabd9ab9d211063658a21/klog.go#L809) 
May be we should use `InfoS` instead of `Errors`.


_Originally posted by @yuzhiquan in https://github.com/kubernetes/kubernetes/issues/98976#issuecomment-791354062_

**What did you expect to happen:**

Error is nil should not change the log level

**Anything else you would like to add:**
[Miscellaneous information that will assist in solving the issue.]

/cc @serathius @ehashman
/priority important-soon


Pull request:
Fix err is nil,ErrorS should not change the log level
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, read our contributor guidelines https://git.k8s.io/community/contributors/guide/pull-requests.md#the-pull-request-submit-process and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
2. If you want *faster* PR reviews, read how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
3. Follow the instructions for writing a release note: https://git.k8s.io/community/contributors/guide/release-notes.md
4. If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests
5. If this PR changes image versions, please title this PR "Bump <image name> from x.x.x to y.y.y."
-->

**What this PR does / why we need it**:
Fix when err is nil,ErrorS does not change the log level
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #216 

**Special notes for your reviewer**:

_Please confirm that if this PR changes any image versions, then that's the sole change this PR makes._

**Release note**:
<!--  Write your release note:
1. Enter your extended release note in the below block. If the PR requires additional action from users switching to the new release, include the string "action required".
2. If no release note is required, just write "NONE".
-->
```release-note
NONE
```

/assign @serathius @ehashman

Patch:
diff --git a/klog.go b/klog.go
index e850db6..e042e2b 100644
--- a/klog.go
+++ b/klog.go
@@ -780,7 +780,7 @@ func (l *loggingT) errorS(err error, loggr logr.Logger, filter LogFilter, depth
 		loggr.Error(err, msg, keysAndValues...)
 		return
 	}
-	l.printS(err, depth+1, msg, keysAndValues...)
+	l.printS(err, errorLog, depth+1, msg, keysAndValues...)
 }
 
 // if loggr is specified, will call loggr.Info, otherwise output with logging module.
@@ -792,12 +792,12 @@ func (l *loggingT) infoS(loggr logr.Logger, filter LogFilter, depth int, msg str
 		loggr.Info(msg, keysAndValues...)
 		return
 	}
-	l.printS(nil, depth+1, msg, keysAndValues...)
+	l.printS(nil, infoLog, depth+1, msg, keysAndValues...)
 }
 
 // printS is called from infoS and errorS if loggr is not specified.
-// if err arguments is specified, will output to errorLog severity
-func (l *loggingT) printS(err error, depth int, msg string, keysAndValues ...interface{}) {
+// set log severity by s
+func (l *loggingT) printS(err error, s severity, depth int, msg string, keysAndValues ...interface{}) {
 	b := &bytes.Buffer{}
 	b.WriteString(fmt.Sprintf("%q", msg))
 	if err != nil {
@@ -805,12 +805,6 @@ func (l *loggingT) printS(err error, depth int, msg string, keysAndValues ...int
 		b.WriteString(fmt.Sprintf("err=%q", err.Error()))
 	}
 	kvListFormat(b, keysAndValues...)
-	var s severity
-	if err == nil {
-		s = infoLog
-	} else {
-		s = errorLog
-	}
 	l.printDepth(s, logging.logr, nil, depth+1, b)
 }
 


Test patch:
diff --git a/klog_test.go b/klog_test.go
index ecdc19a..ba4349b 100644
--- a/klog_test.go
+++ b/klog_test.go
@@ -952,17 +952,31 @@ func TestErrorS(t *testing.T) {
 		myErrorS,
 	}
 	for _, f := range functions {
-		logging.file[errorLog] = &flushBuffer{}
-		f(fmt.Errorf("update status failed"), "Failed to update pod status", "pod", "kubedns")
-		var line int
-		format := "E0102 15:04:05.067890    1234 klog_test.go:%d] \"Failed to update pod status\" err=\"update status failed\" pod=\"kubedns\"\n"
-		n, err := fmt.Sscanf(contents(errorLog), format, &line)
-		if n != 1 || err != nil {
-			t.Errorf("log format error: %d elements, error %s:\n%s", n, err, contents(errorLog))
+		var errorList = []struct {
+			err    error
+			format string
+		}{
+			{
+				err:    fmt.Errorf("update status failed"),
+				format: "E0102 15:04:05.067890    1234 klog_test.go:%d] \"Failed to update pod status\" err=\"update status failed\" pod=\"kubedns\"\n",
+			},
+			{
+				err:    nil,
+				format: "E0102 15:04:05.067890    1234 klog_test.go:%d] \"Failed to update pod status\" pod=\"kubedns\"\n",
+			},
 		}
-		want := fmt.Sprintf(format, line)
-		if contents(errorLog) != want {
-			t.Errorf("ErrorS has wrong format: \n got:\t%s\nwant:\t%s", contents(errorLog), want)
+		for _, e := range errorList {
+			logging.file[errorLog] = &flushBuffer{}
+			f(e.err, "Failed to update pod status", "pod", "kubedns")
+			var line int
+			n, err := fmt.Sscanf(contents(errorLog), e.format, &line)
+			if n != 1 || err != nil {
+				t.Errorf("log format error: %d elements, error %s:\n%s", n, err, contents(errorLog))
+			}
+			want := fmt.Sprintf(e.format, line)
+			if contents(errorLog) != want {
+				t.Errorf("ErrorS has wrong format: \n got:\t%s\nwant:\t%s", contents(errorLog), want)
+			}
 		}
 	}
 }