diff --git a/client/cmd/root.go b/client/cmd/root.go index 2cdf5a77a..baf444b99 100644 --- a/client/cmd/root.go +++ b/client/cmd/root.go @@ -21,8 +21,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - grpcLogger "github.com/netbirdio/netbird/client/grpc/logger" - "github.com/netbirdio/netbird/client/internal" ) @@ -243,7 +241,6 @@ func DialClientGRPCServer(ctx context.Context, addr string) (*grpc.ClientConn, e strings.TrimPrefix(addr, "tcp://"), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), - grpc.WithUnaryInterceptor(grpcLogger.UnaryClientInterceptor()), ) } diff --git a/client/grpc/logger/logger.go b/client/grpc/logger/logger.go deleted file mode 100644 index 41af9295e..000000000 --- a/client/grpc/logger/logger.go +++ /dev/null @@ -1,65 +0,0 @@ -package logger - -import ( - "context" - "os" - "time" - - log "github.com/sirupsen/logrus" - "google.golang.org/grpc" - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/proto" -) - -// UnaryClientInterceptor logs gRPC requests using the global logrus logger -func UnaryClientInterceptor() grpc.UnaryClientInterceptor { - return func( - ctx context.Context, - method string, - req, reply interface{}, - cc *grpc.ClientConn, - invoker grpc.UnaryInvoker, - opts ...grpc.CallOption, - ) error { - start := time.Now() - - // don't log if log output is not a file - ignoreLog := log.StandardLogger().Out == os.Stdout || log.StandardLogger().Out == os.Stderr - - if !ignoreLog { - // log the request - if msg, ok := req.(proto.Message); ok { - if jsonReq, err := protojson.Marshal(msg); err == nil { - log.Debugf("gRPC request initiated: method=%s, request=%s", method, jsonReq) - } else { - log.Warnf("Could not marshal gRPC request: method=%s, error=%v", method, err) - } - } else { - log.Debugf("gRPC request initiated: method=%s, requestType=%T", method, req) - } - } - - err := invoker(ctx, method, req, reply, cc, opts...) - - duration := time.Since(start) - - // log the response - if !ignoreLog { - if err != nil { - log.Errorf("gRPC request failed: method=%s, duration=%v, error=%v", method, duration, err) - } else { - if msg, ok := reply.(proto.Message); ok { - if jsonReply, err := protojson.Marshal(msg); err == nil { - log.Debugf("gRPC request succeeded: method=%s, duration=%v, response=%s", method, duration, jsonReply) - } else { - log.Warnf("Could not marshal gRPC response: method=%s, error=%v", method, err) - } - } else { - log.Debugf("gRPC request succeeded: method=%s, duration=%v, responseType=%T", method, duration, reply) - } - } - } - - return err - } -} diff --git a/client/ui/client_ui.go b/client/ui/client_ui.go index 57aa85d02..b2a6404bb 100644 --- a/client/ui/client_ui.go +++ b/client/ui/client_ui.go @@ -38,8 +38,6 @@ import ( "github.com/netbirdio/netbird/client/ui/process" "github.com/netbirdio/netbird/util" - grpcLogger "github.com/netbirdio/netbird/client/grpc/logger" - "github.com/netbirdio/netbird/version" ) @@ -824,7 +822,6 @@ func (s *serviceClient) getSrvClient(timeout time.Duration) (proto.DaemonService strings.TrimPrefix(s.addr, "tcp://"), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), - grpc.WithUnaryInterceptor(grpcLogger.UnaryClientInterceptor()), grpc.WithUserAgent(desktop.GetUIUserAgent()), ) if err != nil { diff --git a/util/grpc/dialer.go b/util/grpc/dialer.go index dbc642ebf..f6d6d2f04 100644 --- a/util/grpc/dialer.go +++ b/util/grpc/dialer.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" - grpcLogger "github.com/netbirdio/netbird/client/grpc/logger" "github.com/netbirdio/netbird/util/embeddedroots" nbnet "github.com/netbirdio/netbird/util/net" ) @@ -85,7 +84,6 @@ func CreateConnection(addr string, tlsEnabled bool) (*grpc.ClientConn, error) { Time: 30 * time.Second, Timeout: 10 * time.Second, }), - grpc.WithUnaryInterceptor(grpcLogger.UnaryClientInterceptor()), ) if err != nil { log.Printf("DialContext error: %v", err)