Documentation ¶
Index ¶
- func LoggerFromCtx(ctx context.Context) zerolog.Logger
- func NewLoggingMiddleware(logger zerolog.Logger, logRPCLevel zerolog.Level, logReqLevel zerolog.Level, ...) (unary UnaryServerMiddleware, stream StreamServerMiddleware)
- func NewStreamClientMiddlewareInterceptor(middleware ...StreamClientMiddleware) grpc.StreamClientInterceptor
- func NewStreamServerMiddlewareInterceptor(middleware ...StreamServerMiddleware) grpc.StreamServerInterceptor
- func NewUnaryClientMiddlewareInterceptor(middleware ...UnaryClientMiddleware) grpc.UnaryClientInterceptor
- func NewUnaryServerMiddlewareInterceptor(middleware ...UnaryServerMiddleware) grpc.UnaryServerInterceptor
- type StreamClientHandler
- type StreamClientMiddleware
- type StreamServerHandler
- type StreamServerMiddleware
- type UnaryClientHandler
- type UnaryClientMiddleware
- type UnaryServerHandler
- type UnaryServerMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggerFromCtx ¶
LoggerFromCtx returns a method or stream-specific logger with context fields already set by the logging middleware.
If logging middleware is not in use, this method panic
func NewLoggingMiddleware ¶
func NewLoggingMiddleware( logger zerolog.Logger, logRPCLevel zerolog.Level, logReqLevel zerolog.Level, logRespLevel zerolog.Level, logErrors bool, errorTrace bool, ) (unary UnaryServerMiddleware, stream StreamServerMiddleware)
NewLoggingMiddleware creates unary and streaming middleware for logging requests.
logger is the zerolog.Logger to use.
logRpcLevel is what level to log rpcCalls at. The method name, duration and id of the request will be logged.
logReqLevel will log the req value on the rpc log if the logger is equal to or under the level cutoff.
logRespLevel will log the resp value in the rpc log if the logger is equal to ot under the level cutoff.
logErrors: when tue, errors will be logged at an error level if they occur.
errorTrace: when true, a Trace() will be added to error logs.
func NewStreamClientMiddlewareInterceptor ¶
func NewStreamClientMiddlewareInterceptor( middleware ...StreamClientMiddleware, ) grpc.StreamClientInterceptor
NewStreamClientMiddlewareInterceptor returns a grpc.StreamClientInterceptor that invokes all middleware on each client streaming rpc method.
func NewStreamServerMiddlewareInterceptor ¶
func NewStreamServerMiddlewareInterceptor( middleware ...StreamServerMiddleware, ) grpc.StreamServerInterceptor
func NewUnaryClientMiddlewareInterceptor ¶
func NewUnaryClientMiddlewareInterceptor( middleware ...UnaryClientMiddleware, ) grpc.UnaryClientInterceptor
NewUnaryClientMiddlewareInterceptor creates a new grpc.UnaryClientInterceptor which invokes the passed middleware on each unary rpc.
func NewUnaryServerMiddlewareInterceptor ¶
func NewUnaryServerMiddlewareInterceptor( middleware ...UnaryServerMiddleware, ) grpc.UnaryServerInterceptor
NewUnaryServeMiddlewareInterceptor creates an interceptor that calls invokes multiple middlewares on each request.
Types ¶
type StreamClientHandler ¶
type StreamClientHandler = func( ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption, ) (grpc.ClientStream, error)
StreamClientHandler is the handler signature for a stream client rpc.
type StreamClientMiddleware ¶
type StreamClientMiddleware = func(next StreamClientHandler) StreamClientHandler
StreamClientHandler is the handler signature for stream client middleware.
type StreamServerHandler ¶
type StreamServerHandler = func( srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, ) (err error)
StreamServerHandler is the handler signature for stream server calls.
type StreamServerMiddleware ¶
type StreamServerMiddleware = func(next StreamServerHandler) StreamServerHandler
StreamServerMiddleware is the middleware signature for stream server calls.
func NewStreamLoggingMiddleware ¶
func NewStreamLoggingMiddleware( logger zerolog.Logger, logRPCLevel zerolog.Level, logReqLevel zerolog.Level, logRespLevel zerolog.Level, logErrors bool, errorTrace bool, ) StreamServerMiddleware
NewStreamLoggingMiddleware creates a new StreamServerMiddleware for logging gRPC server streams.
type UnaryClientHandler ¶
type UnaryClientHandler = func( ctx context.Context, method string, req interface{}, cc *grpc.ClientConn, opts ...grpc.CallOption, ) (reply interface{}, err error)
UnaryClientHandler is the handler signature for a unary client rpc.
type UnaryClientMiddleware ¶
type UnaryClientMiddleware = func(next UnaryClientHandler) UnaryClientHandler
UnaryClientHandler is the handler signature for unary client middleware.
type UnaryServerHandler ¶
type UnaryServerHandler = func( ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ) (resp interface{}, err error)
UnaryServerHandler is the handler signature for unary server calls.
type UnaryServerMiddleware ¶
type UnaryServerMiddleware = func(next UnaryServerHandler) UnaryServerHandler
UnaryServerMiddleware is the middleware signature for unary server calls.
func NewUnaryLoggingMiddleware ¶
func NewUnaryLoggingMiddleware( logger zerolog.Logger, logRPCLevel zerolog.Level, logReqLevel zerolog.Level, logRespLevel zerolog.Level, logErrors bool, errorTrace bool, ) UnaryServerMiddleware
NewUnaryLoggingMiddleware creates a new UnaryServerMiddleware for logging gRPC server unary requests.