Documentation ¶
Overview ¶
Package logging implements grpc logging middleware.
Index ¶
- func DefaultCodeToLevel(code codes.Code) logging.Level
- func FullMethod(service, method string) string
- func StreamClientInterceptor(logger logging.Logger, opts ...Option) grpc.StreamClientInterceptor
- func StreamServerInterceptor(logger logging.Logger, opts ...Option) grpc.StreamServerInterceptor
- func UnaryClientInterceptor(logger logging.Logger, opts ...Option) grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(logger logging.Logger, opts ...Option) grpc.UnaryServerInterceptor
- type Decider
- type Option
- type PayloadDecision
- type RequestFieldExtractorFunc
- type ResponseFieldExtractorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCodeToLevel ¶
DefaultCodeToLevel the default grpc status code to log level
func FullMethod ¶ added in v0.2.21
func StreamClientInterceptor ¶
func StreamClientInterceptor(logger logging.Logger, opts ...Option) grpc.StreamClientInterceptor
StreamClientInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls. Logger will use all tags (from tags package) available in current context as fields.
func StreamServerInterceptor ¶
func StreamServerInterceptor(logger logging.Logger, opts ...Option) grpc.StreamServerInterceptor
StreamServerInterceptor returns a new stream server interceptors that optionally logs endpoint handling. Logger will use all tags (from tags package) available in current context as fields.
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(logger logging.Logger, opts ...Option) grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a new unary client interceptor that optionally logs the execution of external gRPC calls. Logger will use all tags (from tags package) available in current context as fields.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(logger logging.Logger, opts ...Option) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptors that optionally logs endpoint handling. Logger will use all tags (from tags package) available in current context as fields.
Types ¶
type Decider ¶
type Decider func(fullMethod string, err error) PayloadDecision
Decider function defines rules for suppressing any interceptor logs
type Option ¶
type Option func(*options)
Option the Options for this module
func WithDecider ¶
WithDecider customizes the function for deciding if the gRPC interceptor logs should log.
func WithLevels ¶
func WithLevels(f logging.CodeToLevel) Option
WithLevels customizes the function for mapping gRPC return codes and interceptor log level statements.
func WithRequestFieldExtractorFunc ¶
func WithRequestFieldExtractorFunc(f RequestFieldExtractorFunc) Option
WithRequestFieldExtractorFunc customizes the function for extracting log fields from protobuf messages, for unary and server-streamed methods only.
func WithResponseFieldExtractorFunc ¶
func WithResponseFieldExtractorFunc(f ResponseFieldExtractorFunc) Option
WithResponseFieldExtractorFunc customizes the function for extracting log fields from protobuf messages, for unary and server-streamed methods only.
type PayloadDecision ¶
PayloadDecision defines rules for enabling Request or Response logging
func DefaultLoggingDeciderMethod ¶
func DefaultLoggingDeciderMethod(_ string, _ error) PayloadDecision
DefaultLoggingDeciderMethod is the default implementation of decider to see if you should log the call by default this if always true so all calls are logged
type RequestFieldExtractorFunc ¶
RequestFieldExtractorFunc is a user-provided function that extracts field information from a gRPC request. It is called from tags middleware on arrival of unary request or a server-stream request. Keys and values will be added to the context tags of the request. If there are no fields, you should return a nil.
type ResponseFieldExtractorFunc ¶
ResponseFieldExtractorFunc is a user-provided function that extracts field information from a gRPC response. It is called from tags middleware on arrival of unary request or a server-stream request. Keys and values will be added to the context tags of the request. If there are no fields, you should return a nil.