Skip to content

Commit

Permalink
Merge pull request #216 from projectsyn/fix-cr-no-logger
Browse files Browse the repository at this point in the history
Add minimal logger for controller runtime
  • Loading branch information
bastjan authored May 28, 2024
2 parents 742dad4 + 2f05228 commit 1f2f2f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/deepmap/oapi-codegen v1.16.2
github.com/deepmap/oapi-codegen/v2 v2.1.0
github.com/getkin/kin-openapi v0.123.0
github.com/go-logr/logr v1.4.2
github.com/hashicorp/golang-lru v1.0.2
github.com/labstack/echo/v4 v4.12.0
github.com/oapi-codegen/runtime v1.1.1
Expand All @@ -35,7 +36,6 @@ require (
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/projectsyn/lieutenant-operator v1.5.3 h1:n2gIWvws+hy5WxbcgiW5Pf3lNbcsrEC6vL9DBzp1Ves=
github.com/projectsyn/lieutenant-operator v1.5.3/go.mod h1:JIIxR4epvsV57V1nb+f1yIFZ4wQJAgvpnkCrmY/xowA=
github.com/projectsyn/lieutenant-operator v1.6.0 h1:9ACzJjjBAonAGu5SkaPMzfZ9e94vJq663BPic1Vq55c=
github.com/projectsyn/lieutenant-operator v1.6.0/go.mod h1:JIIxR4epvsV57V1nb+f1yIFZ4wQJAgvpnkCrmY/xowA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"os"

_ "github.com/cosmtrek/air/runner" // used for hot reload
"github.com/go-logr/logr"
"github.com/go-logr/logr/funcr"
"github.com/projectsyn/lieutenant-api/pkg/service"
crlog "sigs.k8s.io/controller-runtime/pkg/log"
)

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

func main() {
crlog.SetLogger(newStdoutLogger())

conf := service.APIConfig{
APIVersion: Version,
Namespace: os.Getenv("NAMESPACE"),
Expand All @@ -34,3 +39,13 @@ func main() {

e.Logger.Fatal(e.Start(":8080"))
}

func newStdoutLogger() logr.Logger {
return funcr.New(func(prefix, args string) {
if prefix != "" {
fmt.Printf("%s: %s\n", prefix, args)
} else {
fmt.Println(args)
}
}, funcr.Options{})
}

0 comments on commit 1f2f2f6

Please sign in to comment.