Skip to content

Commit

Permalink
Merge pull request #151 from nrjpoddar/skipContextCancelledLog
Browse files Browse the repository at this point in the history
Skip logging context cancelled warning msgs
  • Loading branch information
bboreham authored Apr 3, 2019
2 parents 81a1a4d + 2c39cd4 commit c07ae0c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions middleware/grpc_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func (s GRPCServerLog) UnaryServerInterceptor(ctx context.Context, req interface
if s.WithRequest {
entry = entry.WithField("request", req)
}
entry.WithField(errorKey, err).Warnln(gRPC)
if err == context.Canceled {
entry.WithField(errorKey, err).Debugln(gRPC)
} else {
entry.WithField(errorKey, err).Warnln(gRPC)
}
} else {
entry.Debugf("%s (success)", gRPC)
}
Expand All @@ -44,7 +48,11 @@ func (s GRPCServerLog) StreamServerInterceptor(srv interface{}, ss grpc.ServerSt
err := handler(srv, ss)
entry := user.LogWith(ss.Context(), s.Log).WithFields(logging.Fields{"method": info.FullMethod, "duration": time.Since(begin)})
if err != nil {
entry.WithField(errorKey, err).Warnln(gRPC)
if err == context.Canceled {
entry.WithField(errorKey, err).Debugln(gRPC)
} else {
entry.WithField(errorKey, err).Warnln(gRPC)
}
} else {
entry.Debugf("%s (success)", gRPC)
}
Expand Down

0 comments on commit c07ae0c

Please sign in to comment.