Skip to content

Commit

Permalink
Replace main logging structure
Browse files Browse the repository at this point in the history
  • Loading branch information
zachfi committed Apr 7, 2024
1 parent 8039d03 commit cca2636
Show file tree
Hide file tree
Showing 25 changed files with 14 additions and 1,990 deletions.
2 changes: 1 addition & 1 deletion build/release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ release-publish: clean tools docker-login release-notes
snapshot: release-clean
@echo "=== $(PROJECT_NAME) === [ snapshot ]: Creating release via $(REL_CMD)"
@echo "=== $(PROJECT_NAME) === [ snapshot ]: THIS WILL NOT BE PUBLISHED!"
$(REL_CMD) --skip-publish --snapshot
$(REL_CMD) --skip=publish --snapshot

.PHONY: release release-clean release-publish snapshot
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.22

require (
github.com/go-ini/ini v1.67.0
github.com/go-kit/log v0.2.1
github.com/go-logr/logr v1.4.1
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.18.1
Expand Down Expand Up @@ -38,7 +37,6 @@ require (
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,9 @@ github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3I
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down
21 changes: 13 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ package main
import (
"flag"
"fmt"
"log/slog"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.

_ "k8s.io/client-go/plugin/pkg/client/auth"

"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

"go.opentelemetry.io/otel"

Expand All @@ -40,7 +41,6 @@ import (

//+kubebuilder:scaffold:imports

"github.com/go-kit/log"
"github.com/zachfi/zkit/pkg/tracing"
)

Expand Down Expand Up @@ -99,13 +99,18 @@ func main() {
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
opts := zap.Options{
Development: true,
}
opts.BindFlags(flag.CommandLine)
flag.Parse()

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
opts := &slog.HandlerOptions{
Level: slog.LevelInfo,
}

// We have multiple loggers, using slog as a base handler.
handler := slog.NewTextHandler(os.Stdout, opts)
logger := slog.New(handler)
slogger := logr.FromSlogHandler(handler)

ctrl.SetLogger(slogger)

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Expand Down Expand Up @@ -165,7 +170,7 @@ func main() {
OtelEndpoint: otelEndpoint,
OrgID: orgID,
},
log.NewLogfmtLogger(os.Stderr),
logger,
"nodemanager",
versionString(),
)
Expand Down
15 changes: 0 additions & 15 deletions vendor/github.com/go-kit/log/.gitignore

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/go-kit/log/LICENSE

This file was deleted.

156 changes: 0 additions & 156 deletions vendor/github.com/go-kit/log/README.md

This file was deleted.

Loading

0 comments on commit cca2636

Please sign in to comment.