...
1
2
3
4 package grpc_logging
5
6 import (
7 "context"
8 "io"
9
10 "github.com/golang/protobuf/proto"
11 "google.golang.org/grpc/codes"
12 "google.golang.org/grpc/status"
13 )
14
15
16
17 type ErrorToCode func(err error) codes.Code
18
19 func DefaultErrorToCode(err error) codes.Code {
20 return status.Code(err)
21 }
22
23
24 type Decider func(fullMethodName string, err error) bool
25
26
27
28 func DefaultDeciderMethod(fullMethodName string, err error) bool {
29 return true
30 }
31
32
33
34 type ServerPayloadLoggingDecider func(ctx context.Context, fullMethodName string, servingObject interface{}) bool
35
36
37
38 type ClientPayloadLoggingDecider func(ctx context.Context, fullMethodName string) bool
39
40
41 type JsonPbMarshaler interface {
42 Marshal(out io.Writer, pb proto.Message) error
43 }
44
View as plain text