11
11
It accepts a user-configured ` logrus.Entry ` that will be used for logging completed gRPC calls. The same
12
12
` logrus.Entry ` will be used for logging completed gRPC calls, and be populated into the ` context.Context ` passed into gRPC handler code.
13
13
14
- You can use ` Extract ` to log into a request-scoped ` logrus.Entry ` instance in your handler code. The fields set on the
15
- logger correspond to the grpc_ctxtags.Tags attached to the context.
16
-
17
- As ` Extract ` will iterate all tags on from ` grpc_ctxtags ` it is therefore expensive so it is advised that you
18
- extract once at the start of the function from the context and reuse it for the remainder of the function (see examples).
14
+ On calling ` StreamServerInterceptor ` or ` UnaryServerInterceptor ` this logging middleware will add gRPC call information
15
+ to the ctx so that it will be present on subsequent use of the ` ctx_zap ` logger.
19
16
20
17
This package also implements request and response * payload* logging, both for server-side and client-side. These will be
21
18
logged as structured ` jsonbp ` fields for every message received/sent (both unary and streaming). For that please use
@@ -32,7 +29,7 @@ Please see examples and tests for examples of use.
32
29
- [ github.com/golang/protobuf/proto] ( https://godoc.org/github.com/golang/protobuf/proto )
33
30
- [ github.com/grpc-ecosystem/go-grpc-middleware] ( ./../.. )
34
31
- [ github.com/grpc-ecosystem/go-grpc-middleware/logging] ( ./.. )
35
- - [ github.com/grpc-ecosystem/go-grpc-middleware/tags] ( ./../../tags )
32
+ - [ github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus ] ( ./../../tags/logrus )
36
33
- [ github.com/sirupsen/logrus] ( https://godoc.org/github.com/sirupsen/logrus )
37
34
- [ golang.org/x/net/context] ( https://godoc.org/golang.org/x/net/context )
38
35
- [ google.golang.org/grpc] ( https://godoc.org/google.golang.org/grpc )
@@ -64,7 +61,7 @@ Please see examples and tests for examples of use.
64
61
* [ func WithLevels(f CodeToLevel) Option] ( #WithLevels )
65
62
66
63
#### <a name =" pkg-files " >Package files</a >
67
- [ client_interceptors.go] ( ./client_interceptors.go ) [ context.go] ( ./context.go ) [ doc.go] ( ./doc.go ) [ grpclogger.go] ( ./grpclogger.go ) [ noop.go ] ( ./noop.go ) [ options.go] ( ./options.go ) [ payload_interceptors.go] ( ./payload_interceptors.go ) [ server_interceptors.go] ( ./server_interceptors.go )
64
+ [ client_interceptors.go] ( ./client_interceptors.go ) [ context.go] ( ./context.go ) [ doc.go] ( ./doc.go ) [ grpclogger.go] ( ./grpclogger.go ) [ options.go] ( ./options.go ) [ payload_interceptors.go] ( ./payload_interceptors.go ) [ server_interceptors.go] ( ./server_interceptors.go )
68
65
69
66
## <a name =" pkg-variables " >Variables</a >
70
67
``` go
@@ -88,11 +85,12 @@ var (
88
85
)
89
86
```
90
87
91
- ## <a name =" AddFields " >func</a > [ AddFields] ( ./context.go#L24 )
88
+ ## <a name =" AddFields " >func</a > [ AddFields] ( ./context.go#L11 )
92
89
``` go
93
90
func AddFields (ctx context .Context , fields logrus .Fields )
94
91
```
95
92
AddFields adds logrus fields to the logger.
93
+ Deprecated: should use the ctx_logrus.Extract instead
96
94
97
95
## <a name="DefaultClientCodeToLevel">func</a> [DefaultClientCodeToLevel](./options.go#L120)
98
96
``` go
@@ -118,22 +116,20 @@ func DurationToTimeMillisField(duration time.Duration) (key string, value interf
118
116
```
119
117
DurationToTimeMillisField converts the duration to milliseconds and uses the key ` grpc.time_ms ` .
120
118
121
- ## <a name =" Extract " >func</a > [ Extract] ( ./context.go#L38 )
119
+ ## <a name =" Extract " >func</a > [ Extract] ( ./context.go#L17 )
122
120
``` go
123
121
func Extract (ctx context .Context ) *logrus .Entry
124
122
```
125
123
Extract takes the call-scoped logrus.Entry from grpc_logrus middleware.
124
+ Deprecated: should use the ctx_logrus.Extract instead
126
125
127
- If the grpc_logrus middleware wasn't used, a no-op `logrus.Entry` is returned. This makes it safe to
128
- use regardless.
129
-
130
- ## <a name="PayloadStreamClientInterceptor">func</a> [PayloadStreamClientInterceptor](./payload_interceptors.go#L77)
126
+ ## <a name="PayloadStreamClientInterceptor">func</a> [PayloadStreamClientInterceptor](./payload_interceptors.go#L74)
131
127
``` go
132
128
func PayloadStreamClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.StreamClientInterceptor
133
129
```
134
130
PayloadStreamServerInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
135
131
136
- ## <a name="PayloadStreamServerInterceptor">func</a> [PayloadStreamServerInterceptor](./payload_interceptors.go#L48 )
132
+ ## <a name="PayloadStreamServerInterceptor">func</a> [PayloadStreamServerInterceptor](./payload_interceptors.go#L45 )
137
133
``` go
138
134
func PayloadStreamServerInterceptor(entry *logrus.Entry, decider grpc_logging.ServerPayloadLoggingDecider) grpc.StreamServerInterceptor
139
135
```
@@ -142,13 +138,13 @@ PayloadUnaryServerInterceptor returns a new server server interceptors that logs
142
138
This *only* works when placed *after* the `grpc_logrus.StreamServerInterceptor`. However, the logging can be done to a
143
139
separate instance of the logger.
144
140
145
- ## <a name="PayloadUnaryClientInterceptor">func</a> [PayloadUnaryClientInterceptor](./payload_interceptors.go#L61 )
141
+ ## <a name="PayloadUnaryClientInterceptor">func</a> [PayloadUnaryClientInterceptor](./payload_interceptors.go#L58 )
146
142
``` go
147
143
func PayloadUnaryClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.UnaryClientInterceptor
148
144
```
149
145
PayloadUnaryClientInterceptor returns a new unary client interceptor that logs the paylods of requests and responses.
150
146
151
- ## <a name="PayloadUnaryServerInterceptor">func</a> [PayloadUnaryServerInterceptor](./payload_interceptors.go#L28 )
147
+ ## <a name="PayloadUnaryServerInterceptor">func</a> [PayloadUnaryServerInterceptor](./payload_interceptors.go#L25 )
152
148
``` go
153
149
func PayloadUnaryServerInterceptor(entry *logrus.Entry, decider grpc_logging.ServerPayloadLoggingDecider) grpc.UnaryServerInterceptor
154
150
```
@@ -170,7 +166,7 @@ func StreamClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamCli
170
166
```
171
167
StreamServerInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.
172
168
173
- ## <a name="StreamServerInterceptor">func</a> [StreamServerInterceptor](./server_interceptors.go#L50 )
169
+ ## <a name="StreamServerInterceptor">func</a> [StreamServerInterceptor](./server_interceptors.go#L48 )
174
170
``` go
175
171
func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor
176
172
```
@@ -182,7 +178,7 @@ func UnaryClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryClien
182
178
```
183
179
UnaryClientInterceptor returns a new unary client interceptor that optionally logs the execution of external gRPC calls.
184
180
185
- ## <a name="UnaryServerInterceptor">func</a> [UnaryServerInterceptor](./server_interceptors.go#L25 )
181
+ ## <a name="UnaryServerInterceptor">func</a> [UnaryServerInterceptor](./server_interceptors.go#L23 )
186
182
``` go
187
183
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor
188
184
```
0 commit comments