Skip to content

Commit 1f2f2f6

Browse files
authored
Merge pull request #216 from projectsyn/fix-cr-no-logger
Add minimal logger for controller runtime
2 parents 742dad4 + 2f05228 commit 1f2f2f6

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/deepmap/oapi-codegen v1.16.2
1111
github.com/deepmap/oapi-codegen/v2 v2.1.0
1212
github.com/getkin/kin-openapi v0.123.0
13+
github.com/go-logr/logr v1.4.2
1314
github.com/hashicorp/golang-lru v1.0.2
1415
github.com/labstack/echo/v4 v4.12.0
1516
github.com/oapi-codegen/runtime v1.1.1
@@ -35,7 +36,6 @@ require (
3536
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
3637
github.com/fatih/color v1.17.0 // indirect
3738
github.com/fsnotify/fsnotify v1.7.0 // indirect
38-
github.com/go-logr/logr v1.4.2 // indirect
3939
github.com/go-openapi/jsonpointer v0.21.0 // indirect
4040
github.com/go-openapi/jsonreference v0.21.0 // indirect
4141
github.com/go-openapi/swag v0.23.0 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
237237
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
238238
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
239239
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
240-
github.com/projectsyn/lieutenant-operator v1.5.3 h1:n2gIWvws+hy5WxbcgiW5Pf3lNbcsrEC6vL9DBzp1Ves=
241-
github.com/projectsyn/lieutenant-operator v1.5.3/go.mod h1:JIIxR4epvsV57V1nb+f1yIFZ4wQJAgvpnkCrmY/xowA=
242240
github.com/projectsyn/lieutenant-operator v1.6.0 h1:9ACzJjjBAonAGu5SkaPMzfZ9e94vJq663BPic1Vq55c=
243241
github.com/projectsyn/lieutenant-operator v1.6.0/go.mod h1:JIIxR4epvsV57V1nb+f1yIFZ4wQJAgvpnkCrmY/xowA=
244242
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=

main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import (
77
"os"
88

99
_ "github.com/cosmtrek/air/runner" // used for hot reload
10+
"github.com/go-logr/logr"
11+
"github.com/go-logr/logr/funcr"
1012
"github.com/projectsyn/lieutenant-api/pkg/service"
13+
crlog "sigs.k8s.io/controller-runtime/pkg/log"
1114
)
1215

1316
// Version is the lieutenant-api version (set during build)
@@ -17,6 +20,8 @@ var (
1720
)
1821

1922
func main() {
23+
crlog.SetLogger(newStdoutLogger())
24+
2025
conf := service.APIConfig{
2126
APIVersion: Version,
2227
Namespace: os.Getenv("NAMESPACE"),
@@ -34,3 +39,13 @@ func main() {
3439

3540
e.Logger.Fatal(e.Start(":8080"))
3641
}
42+
43+
func newStdoutLogger() logr.Logger {
44+
return funcr.New(func(prefix, args string) {
45+
if prefix != "" {
46+
fmt.Printf("%s: %s\n", prefix, args)
47+
} else {
48+
fmt.Println(args)
49+
}
50+
}, funcr.Options{})
51+
}

0 commit comments

Comments
 (0)