Skip to content

Commit 3957fa9

Browse files
Add zerolog to init
1 parent 6517322 commit 3957fa9

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

go.mod

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@ module github.com/unagex/kondense
33
go 1.21
44

55
require (
6+
github.com/rs/zerolog v1.32.0
67
k8s.io/api v0.29.3
78
k8s.io/apimachinery v0.29.3
89
k8s.io/client-go v0.29.3
910
)
1011

11-
require (
12-
github.com/mattn/go-colorable v0.1.13 // indirect
13-
github.com/mattn/go-isatty v0.0.19 // indirect
14-
)
15-
1612
require (
1713
github.com/davecgh/go-spew v1.1.1 // indirect
1814
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
@@ -28,12 +24,13 @@ require (
2824
github.com/josharian/intern v1.0.0 // indirect
2925
github.com/json-iterator/go v1.1.12 // indirect
3026
github.com/mailru/easyjson v0.7.7 // indirect
27+
github.com/mattn/go-colorable v0.1.13 // indirect
28+
github.com/mattn/go-isatty v0.0.19 // indirect
3129
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3230
github.com/modern-go/reflect2 v1.0.2 // indirect
3331
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
3432
github.com/onsi/ginkgo/v2 v2.17.1 // indirect
3533
github.com/onsi/gomega v1.32.0 // indirect
36-
github.com/rs/zerolog v1.32.0
3734
golang.org/x/net v0.22.0 // indirect
3835
golang.org/x/oauth2 v0.18.0 // indirect
3936
golang.org/x/sys v0.18.0 // indirect

pkg/controller/init.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,12 @@ func (r *Reconciler) getCPUTargetAvg(containerName string) float64 {
276276
if v, ok := os.LookupEnv(env); ok {
277277
target, err := strconv.ParseFloat(v, 64)
278278
if err != nil {
279-
r.L.Printf("error cannot parse environment variable: %s. Set %s to default value: %.2f.",
279+
log.Error().Msgf("error cannot parse environment variable: %s. Set %s to default value: %.2f.",
280280
env, env, DefaultCPUTargetAvg)
281281
return DefaultCPUTargetAvg
282282
}
283283
if target <= 0 || target > 1 {
284-
r.L.Printf("error environment variable :%s should be between 0 and 1. Set %s to default value: %.2f.",
284+
log.Error().Msgf("error environment variable :%s should be between 0 and 1. Set %s to default value: %.2f.",
285285
env, env, DefaultCPUTargetAvg)
286286
return DefaultCPUTargetAvg
287287
}
@@ -311,12 +311,12 @@ func (r *Reconciler) getCPUMaxInc(containerName string) float64 {
311311
if v, ok := os.LookupEnv(env); ok {
312312
maxInc, err := strconv.ParseFloat(v, 64)
313313
if err != nil {
314-
r.L.Printf("error cannot parse environment variable: %s. Set %s to default value: %.2f.",
314+
log.Error().Msgf("error cannot parse environment variable: %s. Set %s to default value: %.2f.",
315315
env, env, DefaultCPUMaxInc)
316316
return DefaultCPUMaxInc
317317
}
318318
if maxInc <= 0 {
319-
r.L.Printf("error environment variable: %s should be bigger than 0. Set %s to default value: %.2f.",
319+
log.Error().Msgf("error environment variable: %s should be bigger than 0. Set %s to default value: %.2f.",
320320
env, env, DefaultCPUMaxInc)
321321
return DefaultCPUMaxInc
322322
}
@@ -331,12 +331,12 @@ func (r *Reconciler) getCPUMaxDec(containerName string) float64 {
331331
if v, ok := os.LookupEnv(env); ok {
332332
maxDec, err := strconv.ParseFloat(v, 64)
333333
if err != nil {
334-
r.L.Printf("error cannot parse environment variable: %s. Set %s to default value: %.2f.",
334+
log.Error().Msgf("error cannot parse environment variable: %s. Set %s to default value: %.2f.",
335335
env, env, DefaultCPUMaxDec)
336336
return DefaultCPUMaxDec
337337
}
338338
if maxDec <= 0 {
339-
r.L.Printf("error environment variable: %s should be bigger than 0. Set %s to default value: %.2f.",
339+
log.Error().Msgf("error environment variable: %s should be bigger than 0. Set %s to default value: %.2f.",
340340
env, env, DefaultCPUMaxDec)
341341
return DefaultCPUMaxDec
342342
}

0 commit comments

Comments
 (0)