Documentation ¶
Overview ¶
Package cloudrequestlog contains primitives for request logging.
Index ¶
- func ErrorDetails(err error) zap.Field
- func WithAdditionalFields(ctx context.Context) context.Context
- type AdditionalFields
- type Config
- type Middleware
- func (l *Middleware) GRPCUnaryClientInterceptor(ctx context.Context, fullMethod string, request interface{}, ...) error
- func (l *Middleware) GRPCUnaryServerInterceptor(ctx context.Context, request interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func (l *Middleware) HTTPServer(next http.Handler) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorDetails ¶
ErrorDetails creates a zap.Field that logs the gRPC error details of the provided error.
Types ¶
type AdditionalFields ¶
type AdditionalFields struct {
// contains filtered or unexported fields
}
AdditionalFields for a request log message.
func GetAdditionalFields ¶
func GetAdditionalFields(ctx context.Context) (*AdditionalFields, bool)
GetAdditionalFields returns the current request metadata.
func (*AdditionalFields) Add ¶
func (m *AdditionalFields) Add(fields ...zap.Field)
Add additional fields.
func (*AdditionalFields) AddToArray ¶
func (m *AdditionalFields) AddToArray(key string, objects ...zapcore.ObjectMarshaler)
AddToArray adds additional objects to an array field.
type Config ¶
type Config struct { // MessageSizeLimit is the maximum size, in bytes, of requests and responses to log. // Messages large than the limit will be truncated. // Default value, 0, means that no messages will be truncated. MessageSizeLimit int `onGCE:"1024"` // CodeToLevel enables overriding the default gRPC code to level conversion. CodeToLevel map[codes.Code]zapcore.Level // StatusToLevel enables overriding the default HTTP status code to level conversion. StatusToLevel map[int]zapcore.Level }
Config contains request logging config.
type Middleware ¶
type Middleware struct { // Config for the request logger middleware. Config Config // MessageTransformer is an optional transform applied to proto.Message request and responses. MessageTransformer func(proto.Message) proto.Message }
Middleware for request logging.
func (*Middleware) GRPCUnaryClientInterceptor ¶
func (l *Middleware) GRPCUnaryClientInterceptor( ctx context.Context, fullMethod string, request interface{}, response interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, ) error
GRPCUnaryClientInterceptor provides request logging as a grpc.UnaryClientInterceptor.
func (*Middleware) GRPCUnaryServerInterceptor ¶
func (l *Middleware) GRPCUnaryServerInterceptor( ctx context.Context, request interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (interface{}, error)
GRPCUnaryServerInterceptor implements request logging as a grpc.UnaryServerInterceptor.
func (*Middleware) HTTPServer ¶
func (l *Middleware) HTTPServer(next http.Handler) http.Handler
HTTPServer provides request logging for HTTP servers.
Click to show internal directories.
Click to hide internal directories.