Skip to content

Commit ef6923e

Browse files
committed
remove use deprecated json package
1 parent 0b537ad commit ef6923e

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

internal/xtest/grpclogger.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ package xtest
22

33
import (
44
"context"
5-
"fmt"
65
"sync/atomic"
76
"testing"
87

9-
"github.com/golang/protobuf/jsonpb"
10-
"github.com/golang/protobuf/proto"
118
"google.golang.org/grpc"
129
)
1310

@@ -42,8 +39,8 @@ func (l GrpcLogger) UnaryClientInterceptor(
4239
"UnaryClientInterceptor: %s - err: %v\n\nreq:\n%v\n\nresp:\n%v",
4340
method,
4441
err,
45-
protoToString(req),
46-
protoToString(reply),
42+
req,
43+
reply,
4744
)
4845
return err
4946
}
@@ -88,24 +85,12 @@ func (g grpcLoggerStream) CloseSend() error {
8885

8986
func (g grpcLoggerStream) SendMsg(m interface{}) error {
9087
err := g.ClientStream.SendMsg(m)
91-
g.t.Logf("SendMsg (streamID: %v) with err '%v':\n%v ", g.streamID, err, protoToString(m))
88+
g.t.Logf("SendMsg (streamID: %v) with err '%v':\n%v ", g.streamID, err, m)
9289
return err
9390
}
9491

9592
func (g grpcLoggerStream) RecvMsg(m interface{}) error {
9693
err := g.ClientStream.RecvMsg(m)
97-
g.t.Logf("RecvMsg (streamID: %v) with err '%v':\n%v ", g.streamID, err, protoToString(m))
94+
g.t.Logf("RecvMsg (streamID: %v) with err '%v':\n%v ", g.streamID, err, m)
9895
return err
9996
}
100-
101-
func protoToString(v interface{}) string {
102-
if mess, ok := v.(proto.Message); ok {
103-
marshaler := jsonpb.Marshaler{}
104-
res, err := marshaler.MarshalToString(mess)
105-
if err != nil {
106-
return fmt.Sprintf("failed to json marshal of: '%v' with err: %v", v, err)
107-
}
108-
return res
109-
}
110-
return fmt.Sprint(v)
111-
}

0 commit comments

Comments
 (0)