MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / initLogging

Function initLogging

cmd/postgres-operator/main.go:71–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69}
70
71func initLogging() {
72 debug := strings.TrimSpace(os.Getenv("CRUNCHY_DEBUG"))
73
74 var verbosity int
75 if strings.EqualFold(debug, "true") {
76 verbosity = 1
77 } else if i, err := strconv.Atoi(debug); err == nil && i > 0 {
78 verbosity = i
79 }
80
81 // Configure a singleton that treats logging.Logger.V(1) as logrus.DebugLevel.
82 logging.SetLogSink(logging.Logrus(os.Stdout, versionString, 1, verbosity))
83
84 global := logging.FromContext(context.Background())
85 runtime.SetLogger(global)
86
87 // [k8s.io/client-go/tools/leaderelection] logs to the global [klog] instance.
88 // - https://github.com/kubernetes-sigs/controller-runtime/issues/2656
89 klog.SetLoggerWithOptions(global, klog.ContextualLogger(true))
90}
91
92//+kubebuilder:rbac:groups="coordination.k8s.io",resources="leases",verbs={get,create,update,watch}
93//+kubebuilder:rbac:groups="authentication.k8s.io",resources="tokenreviews",verbs={create}

Callers 1

mainFunction · 0.85

Calls 4

SetLogSinkFunction · 0.92
LogrusFunction · 0.92
FromContextFunction · 0.92
SetLoggerFunction · 0.92

Tested by

no test coverage detected