Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log message verbosity #106978

Merged
merged 1 commit into from
Jan 12, 2022
Merged

Commits on Jan 12, 2022

  1. avoid klog Info calls without verbosity

    In the following code pattern, the log message will get logged with v=0 in JSON
    output although conceptually it has a higher verbosity:
    
       if klog.V(5).Enabled() {
           klog.Info("hello world")
       }
    
    Having the actual verbosity in the JSON output is relevant, for example for
    filtering out only the important info messages. The solution is to use
    klog.V(5).Info or something similar.
    
    Whether the outer if is necessary at all depends on how complex the parameters
    are. The return value of klog.V can be captured in a variable and be used
    multiple times to avoid the overhead for that function call and to avoid
    repeating the verbosity level.
    pohly committed Jan 12, 2022
    Configuration menu
    Copy the full SHA
    9eaa2dc View commit details
    Browse the repository at this point in the history