https://github.com/philip-bui/grpc-zerolog
Middleware Router logging Protobuf requests, metadata and responses into JSON Logs.
https://github.com/philip-bui/grpc-zerolog
go grpc grpc-zerolog interceptor json logging middleware protobuf protobuf-golang zerolog
Last synced: about 1 month ago
JSON representation
Middleware Router logging Protobuf requests, metadata and responses into JSON Logs.
- Host: GitHub
- URL: https://github.com/philip-bui/grpc-zerolog
- Owner: philip-bui
- License: mit
- Created: 2019-03-15T15:39:42.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-14T19:24:35.000Z (almost 4 years ago)
- Last Synced: 2025-03-28T01:25:48.158Z (about 2 months ago)
- Topics: go, grpc, grpc-zerolog, interceptor, json, logging, middleware, protobuf, protobuf-golang, zerolog
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 23
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gRPC Zerolog
[![BuildStatus Widget]][BuildStatus Result]
[![CodeCov Widget]][CodeCov Result]
[![GoReport Widget]][GoReport Status]
[![GoDoc Widget]][GoDoc][BuildStatus Result]: https://travis-ci.org/philip-bui/grpc-zerolog
[BuildStatus Widget]: https://travis-ci.org/philip-bui/grpc-zerolog.svg?branch=master[CodeCov Result]: https://codecov.io/gh/philip-bui/grpc-zerolog
[CodeCov Widget]: https://codecov.io/gh/philip-bui/grpc-zerolog/branch/master/graph/badge.svg[GoReport Status]: https://goreportcard.com/report/github.com/philip-bui/grpc-zerolog
[GoReport Widget]: https://goreportcard.com/badge/github.com/philip-bui/grpc-zerolog[GoDoc]: https://godoc.org/github.com/philip-bui/grpc-zerolog
[GoDoc Widget]: https://godoc.org/github.com/philip-bui/grpc-zerolog?status.svgImplementation of gRPC Logging Middleware, integrating [Zerolog](https://github.com/rs/zerolog) as a gRPC [Interceptor](https://github.com/grpc-ecosystem/go-grpc-middleware) 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
```go
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](https://github.com/philip-bui/grpc-zerolog/blob/master/LICENSE) for details.