From 420baacb6defda59c3c4da0088804321770c9168 Mon Sep 17 00:00:00 2001 From: SimFG Date: Tue, 9 Apr 2024 16:19:17 +0800 Subject: [PATCH] enhance: use the rate log in the privilege interceptor (#32037) /kind improvement Signed-off-by: SimFG --- internal/proxy/privilege_interceptor.go | 4 ++-- pkg/util/funcutil/policy.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/proxy/privilege_interceptor.go b/internal/proxy/privilege_interceptor.go index 10bec733c5..e8319249b8 100644 --- a/internal/proxy/privilege_interceptor.go +++ b/internal/proxy/privilege_interceptor.go @@ -88,10 +88,10 @@ func PrivilegeInterceptor(ctx context.Context, req interface{}) (context.Context return ctx, nil } log := log.Ctx(ctx) - log.Debug("PrivilegeInterceptor", zap.String("type", reflect.TypeOf(req).String())) + log.RatedDebug(60, "PrivilegeInterceptor", zap.String("type", reflect.TypeOf(req).String())) privilegeExt, err := funcutil.GetPrivilegeExtObj(req) if err != nil { - log.Info("GetPrivilegeExtObj err", zap.Error(err)) + log.RatedInfo(60, "GetPrivilegeExtObj err", zap.Error(err)) return ctx, nil } username, err := GetCurUserFromContext(ctx) diff --git a/pkg/util/funcutil/policy.go b/pkg/util/funcutil/policy.go index 730f01f675..1506ff9abb 100644 --- a/pkg/util/funcutil/policy.go +++ b/pkg/util/funcutil/policy.go @@ -34,17 +34,17 @@ func GetVersion(m proto.GeneratedMessage) (string, error) { func GetPrivilegeExtObj(m proto.GeneratedMessage) (commonpb.PrivilegeExt, error) { _, md := descriptor.MessageDescriptorProto(m) if md == nil { - log.Info("MessageDescriptorProto result is nil") + log.RatedInfo(60, "MessageDescriptorProto result is nil") return commonpb.PrivilegeExt{}, fmt.Errorf("MessageDescriptorProto result is nil") } extObj, err := proto.GetExtension(md.Options, commonpb.E_PrivilegeExtObj) if err != nil { - log.Info("GetExtension fail", zap.Error(err)) + log.RatedInfo(60, "GetExtension fail", zap.Error(err)) return commonpb.PrivilegeExt{}, err } privilegeExt := extObj.(*commonpb.PrivilegeExt) - log.Debug("GetPrivilegeExtObj success", zap.String("resource_type", privilegeExt.ObjectType.String()), zap.String("resource_privilege", privilegeExt.ObjectPrivilege.String())) + log.RatedDebug(60, "GetPrivilegeExtObj success", zap.String("resource_type", privilegeExt.ObjectType.String()), zap.String("resource_privilege", privilegeExt.ObjectPrivilege.String())) return commonpb.PrivilegeExt{ ObjectType: privilegeExt.ObjectType, ObjectPrivilege: privilegeExt.ObjectPrivilege,