Skip to content

Commit c67e504

Browse files
committed
pkg/internal: Add log level constants
These constants can be simply used when logging across the project instead of specifying the level by a number. The descriptions and the values will also guide developers when deciding what log level to choose. For example: ```go import "github.com/openshift/cluster-version-operator/pkg/internal" klog.V(internal.Debug).Infof("") ``` The descriptions of the values are extracted from the used API type [1]. [1]: https://github.com/openshift/api/blob/744790f2cff777b1bb29bdccce10e4e84cff0a69/operator/v1/types.go#L94-L109
1 parent ee8b5ef commit c67e504

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pkg/internal/constants.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package internal
22

3+
import "k8s.io/klog/v2"
4+
35
const (
46
ConfigNamespace = "openshift-config"
57
ConfigManagedNamespace = "openshift-config-managed"
@@ -8,3 +10,22 @@ const (
810
InstallerConfigMap = "openshift-install"
911
ManifestsConfigMap = "openshift-install-manifests"
1012
)
13+
14+
var (
15+
// Normal is the default. Normal, working log information, everything is fine, but helpful notices for auditing or
16+
// common operations. In kube, this is probably glog=2.
17+
Normal klog.Level = 2
18+
19+
// Debug is used when something went wrong. Even common operations may be logged, and less helpful but more
20+
// quantity of notices. In kube, this is probably glog=4.
21+
Debug klog.Level = 4
22+
23+
// Trace is used when something went really badly and even more verbose logs are needed. Logging every function
24+
// call as part of a common operation, to tracing execution of a query. In kube, this is probably glog=6.
25+
Trace klog.Level = 6
26+
27+
// TraceAll is used when something is broken at the level of API content/decoding. It will dump complete body
28+
// content. If you turn this on in a production cluster prepare from serious performance issues and massive
29+
// amounts of logs. In kube, this is probably glog=8.
30+
TraceAll klog.Level = 8
31+
)

0 commit comments

Comments
 (0)