apiserver/pkg/server/httplog
Patrick Ohly ec795ae204 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.

Kubernetes-commit: 9eaa2dc554e0c3d4485d4c916dfdbc2f517db2e0
2021-12-11 12:10:21 +01:00
..
doc.go genericapiserver: fix imports 2017-01-19 10:27:27 -05:00
httplog.go avoid klog Info calls without verbosity 2021-12-11 12:10:21 +01:00
httplog_test.go apiserver: wrap ResponseWriter using abstraction 2021-09-20 11:21:56 -04:00