Skip to content

Commit 96699f6

Browse files
authored
doc_fix:Migrated to structured logging (#5624)
* 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
1 parent d89e944 commit 96699f6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

contributors/devel/sig-instrumentation/logging.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ The following conventions for the klog levels to use.
44
[klog](http://godoc.org/github.com/kubernetes/klog) is globally preferred to
55
[log](http://golang.org/pkg/log/) for better runtime control.
66

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()`,
88
but just return `error`, because client libraries may be used in CLI UIs that wish to control output.
99

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.
1111

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.
1314

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:
1518
* klog.V(0) - Generally useful for this to ALWAYS be visible to an operator
1619
* Programmer errors
1720
* 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
3235
* Context to understand the steps leading up to errors and warnings
3336
* More information for troubleshooting reported issues
3437

35-
* klog.InfoS() - structured logs to the INFO log
36-
3738
As per the comments, the practical default level is V(2). Developers and QE
3839
environments may wish to run at V(3) or V(4). If you wish to change the log
3940
level, you can pass in `-v=X` where X is the desired maximum level to log.

0 commit comments

Comments
 (0)