1.6 KiB
1.6 KiB
gRPC Zerolog
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.