schnutibox/vendor/github.com/philip-bui/grpc-zerolog/README.md
Marvin Preuss 63a16a3253
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone Build was killed
modifies the command line interface handling / timer work
2021-08-09 10:49:04 +02:00

1.6 KiB

gRPC Zerolog

BuildStatus Widget CodeCov Widget GoReport Widget GoDoc Widget

Implementation of gRPC Logging Middleware, integrating Zerolog as a gRPC Interceptor to log the following fields:

  • Request Protobufs as JSON.
  • Response Protobufs as JSON, or Errors.
  • Status Code, Duration, Timestamp, Service Name, Service Method, IP, Metadata Fields and User Agent.

Usage

import (
	"github.com/philip-bui/grpc-zerolog"
)

func main() {
	// With global Zerolog logger.
	grpc.NewServer(
		zerolog.UnaryInterceptor(),
	)

	// With custom Zerolog instance.
	log := zerolog.New(os.Stdout)
	grpc.NewServer(
		zerolog.UnaryInterceptorWithLogger(&log),
	)
}

License

gRPC Zerolog is available under the MIT license. See LICENSE for details.