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
This commit is contained in:
Saptarshi Majumder 2021-03-25 21:17:29 +05:30 committed by GitHub
parent d89e94480f
commit 96699f6d0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -4,14 +4,17 @@ The following conventions for the klog levels to use.
[klog](http://godoc.org/github.com/kubernetes/klog) is globally preferred to
[log](http://golang.org/pkg/log/) for better runtime control.
Shared libraries, such as `client-go`, should not use `klog.Errorf()` and `klog.Warningf()`,
Shared libraries, such as `client-go`, should not use `klog.ErrorS()` and `klog.InfoS()`,
but just return `error`, because client libraries may be used in CLI UIs that wish to control output.
* klog.Errorf() - Always an error
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.
* klog.Warningf() - Something unexpected, but probably not an error
* klog.ErrorS() - Errors should be used to indicate unexpected behaviours in code, like unexpected errors returned by subroutine function calls.
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.
* klog.Infof() has multiple levels:
* 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).
* klog.InfoS() has multiple levels:
* klog.V(0) - Generally useful for this to ALWAYS be visible to an operator
* Programmer errors
* 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
* Context to understand the steps leading up to errors and warnings
* More information for troubleshooting reported issues
* klog.InfoS() - structured logs to the INFO log
As per the comments, the practical default level is V(2). Developers and QE
environments may wish to run at V(3) or V(4). If you wish to change the log
level, you can pass in `-v=X` where X is the desired maximum level to log.