You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* doc_fix:Migrated to structured logging from non-stuctured logging
* doc_fix(update): More details added to each logger command
* doc_fix(update):Adding suggested doc changes
Copy file name to clipboardExpand all lines: contributors/devel/sig-instrumentation/logging.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,17 @@ The following conventions for the klog levels to use.
4
4
[klog](http://godoc.org/github.com/kubernetes/klog) is globally preferred to
5
5
[log](http://golang.org/pkg/log/) for better runtime control.
6
6
7
-
Shared libraries, such as `client-go`, should not use `klog.Errorf()` and `klog.Warningf()`,
7
+
Shared libraries, such as `client-go`, should not use `klog.ErrorS()` and `klog.InfoS()`,
8
8
but just return `error`, because client libraries may be used in CLI UIs that wish to control output.
9
9
10
-
* klog.Errorf() - Always an error
10
+
Please see the [Structured Logging Guide](migration-to-structured-logging.md#structured-logging-in-kubernetes) for more information on how to set keys and values in structured logs.
11
11
12
-
* klog.Warningf() - Something unexpected, but probably not an error
12
+
* klog.ErrorS() - Errors should be used to indicate unexpected behaviours in code, like unexpected errors returned by subroutine function calls.
13
+
Logs generated by `ErrorS` command may be enhanced with additional debug information (by logging library). Calling `ErrorS` with `nil` as error may be acceptable if there is error condition that deserves a stack trace at this origin point.
13
14
14
-
* klog.Infof() has multiple levels:
15
+
* klog.InfoS() - Structured logs to the INFO log. `InfoS` should be used for routine logging. It can also be used to log warnings for expected errors (errors that can happen during routine operations).
16
+
17
+
* klog.InfoS() has multiple levels:
15
18
* klog.V(0) - Generally useful for this to ALWAYS be visible to an operator
16
19
* Programmer errors
17
20
* Logging extra info about a panic
@@ -32,8 +35,6 @@ but just return `error`, because client libraries may be used in CLI UIs that wi
32
35
* Context to understand the steps leading up to errors and warnings
33
36
* More information for troubleshooting reported issues
34
37
35
-
* klog.InfoS() - structured logs to the INFO log
36
-
37
38
As per the comments, the practical default level is V(2). Developers and QE
38
39
environments may wish to run at V(3) or V(4). If you wish to change the log
39
40
level, you can pass in `-v=X` where X is the desired maximum level to log.
0 commit comments