top

`grpc_logrus` is a gRPC logging middleware backed by Logrus loggers

It accepts a user-configured `logrus.Entry` that will be used for logging completed gRPC calls. The same `logrus.Entry` will be used for logging completed gRPC calls, and be populated into the `context.Context` passed into gRPC handler code.

You can use `Extract` to log into a request-scoped `logrus.Entry` instance in your handler code. The fields set on the logger correspond to the grpc_ctxtags.Tags attached to the context.

This package also implements request and response *payload* logging, both for server-side and client-side. These will be logged as structured `jsonbp` fields for every message received/sent (both unary and streaming). For that please use `Payload*Interceptor` functions for that. Please note that the user-provided function that determines whetether to log the full request/response payload needs to be written with care, this can significantly slow down gRPC.

Logrus can also be made as a backend for gRPC library internals. For that use `ReplaceGrpcLogger`.

Please see examples and tests for examples of use.

Imports 10 package(s)

  1. github.com/grpc-ecosystem/go-grpc-middleware
  2. golang.org/x/net/context
  3. google.golang.org/grpc/codes
  4. google.golang.org/grpc
  5. github.com/grpc-ecosystem/go-grpc-middleware/logging
  6. github.com/golang/protobuf/jsonpb
  7. github.com/sirupsen/logrus
  8. google.golang.org/grpc/grpclog
  9. github.com/grpc-ecosystem/go-grpc-middleware/tags
  10. github.com/golang/protobuf/proto

Test imports 6 package(s)

  1. github.com/stretchr/testify/assert
  2. github.com/grpc-ecosystem/go-grpc-middleware/testing
  3. github.com/grpc-ecosystem/go-grpc-middleware/testing/testproto
  4. github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus
  5. github.com/stretchr/testify/require
  6. github.com/stretchr/testify/suite