@@ -29,19 +29,44 @@ func NewGrpcLogger(t testing.TB) GrpcLogger {
2929 return GrpcLogger {t : t }
3030}
3131
32- func (l GrpcLogger ) UnaryClientInterceptor (ctx context.Context , method string , req , reply interface {}, cc * grpc.ClientConn , invoker grpc.UnaryInvoker , opts ... grpc.CallOption ) error {
32+ func (l GrpcLogger ) UnaryClientInterceptor (
33+ ctx context.Context ,
34+ method string ,
35+ req , reply interface {},
36+ cc * grpc.ClientConn ,
37+ invoker grpc.UnaryInvoker ,
38+ opts ... grpc.CallOption ,
39+ ) error {
3340 err := invoker (ctx , method , req , reply , cc , opts ... )
34- l .t .Logf ("UnaryClientInterceptor: %s - err: %v\n \n req:\n %v\n \n resp:\n %v" , method , err , protoToString (req ), protoToString (reply ))
41+ l .t .Logf (
42+ "UnaryClientInterceptor: %s - err: %v\n \n req:\n %v\n \n resp:\n %v" ,
43+ method ,
44+ err ,
45+ protoToString (req ),
46+ protoToString (reply ),
47+ )
3548 return err
3649}
3750
38- func (l GrpcLogger ) StreamClientInterceptor (ctx context.Context , desc * grpc.StreamDesc , cc * grpc.ClientConn , method string , streamer grpc.Streamer , opts ... grpc.CallOption ) (grpc.ClientStream , error ) {
51+ func (l GrpcLogger ) StreamClientInterceptor (
52+ ctx context.Context ,
53+ desc * grpc.StreamDesc ,
54+ cc * grpc.ClientConn ,
55+ method string ,
56+ streamer grpc.Streamer ,
57+ opts ... grpc.CallOption ,
58+ ) (grpc.ClientStream , error ) {
3959 stream , err := streamer (ctx , desc , cc , method , opts ... )
4060 streamWrapper := newGrpcLoggerStream (stream , l .t )
4161 if stream != nil {
4262 stream = streamWrapper
4363 }
44- l .t .Logf ("StreamStart: %v with err '%v' (streamID: %v)" , method , err , streamWrapper .streamID )
64+ l .t .Logf (
65+ "StreamStart: %v with err '%v' (streamID: %v)" ,
66+ method ,
67+ err ,
68+ streamWrapper .streamID ,
69+ )
4570 return stream , err
4671}
4772
@@ -78,7 +103,7 @@ func protoToString(v interface{}) string {
78103 marshaler := jsonpb.Marshaler {}
79104 res , err := marshaler .MarshalToString (mess )
80105 if err != nil {
81- return fmt .Sprintf ("failed to json marshal of: '%v' with err: " , v , err )
106+ return fmt .Sprintf ("failed to json marshal of: '%v' with err: %v " , v , err )
82107 }
83108 return res
84109 }
0 commit comments