From 1811e8190031feb571d98cb0fdfd3775f90c500f Mon Sep 17 00:00:00 2001 From: Mariell Hoversholm Date: Tue, 19 Nov 2024 08:31:51 +0100 Subject: [PATCH] chore: use slog instead of klog --- pkg/registry/apis/provisioning/hello.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/registry/apis/provisioning/hello.go b/pkg/registry/apis/provisioning/hello.go index 538021e9f64..d46fe098885 100644 --- a/pkg/registry/apis/provisioning/hello.go +++ b/pkg/registry/apis/provisioning/hello.go @@ -3,12 +3,12 @@ package provisioning import ( "context" "fmt" + "log/slog" "net/http" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apiserver/pkg/registry/rest" - "k8s.io/klog/v2" "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1" ) @@ -73,7 +73,7 @@ func (s *helloWorldSubresource) Connect(ctx context.Context, name string, opts r name, // resource name rest.DefaultUpdatedObjectInfo(obj, func(ctx context.Context, newObj, oldObj runtime.Object) (transformedNewObj runtime.Object, err error) { newObj.(*v0alpha1.Repository).Status.CurrentGitCommit = newCommit - klog.InfoS("updated the commit", "newObj", newObj, "newCommit", newCommit) + slog.InfoContext(ctx, "updated the commit", "newObj", newObj, "newCommit", newCommit) return newObj, nil }), func(ctx context.Context, obj runtime.Object) error { return nil }, // createValidation @@ -86,14 +86,16 @@ func (s *helloWorldSubresource) Connect(ctx context.Context, name string, opts r return } repo = obj.(*v0alpha1.Repository) - klog.InfoS("the conspicuous boolean", "bool", b) + slog.InfoContext(ctx, "the conspicuous boolean", "bool", b) } - fmt.Printf("GOT: %s/%s\n", repo.Name, repo.Spec.Type) - fmt.Printf(" status: %+v\n", repo.Status) - fmt.Printf(" local: %+v\n", repo.Spec.Local) - fmt.Printf(" github: %+v\n", repo.Spec.GitHub) - fmt.Printf(" s3: %+v\n", repo.Spec.S3) + slog.InfoContext(ctx, "Got a repository", + "name", repo.Name, + "type", repo.Spec.Type, + "status", repo.Status, + "local", repo.Spec.Local, + "github", repo.Spec.GitHub, + "s3", repo.Spec.S3) responder.Object(http.StatusOK, &v0alpha1.HelloWorld{Whom: whom}) }), nil