Documentation
¶
Index ¶
- Variables
- func ClientFilter(opts ...Option) filter.ClientFilter
- func ContextWith(ctx context.Context, logger *zap.Logger) context.Context
- func DefaultCodeToLevel(code int) zapcore.Level
- func DefaultDeciderMethod(fullMethodName string, err error) bool
- func DefaultErrorToCode(err error) int
- func DefaultMessageProducer(ctx context.Context, msg string, level zapcore.Level, code int, err error, ...)
- func DurationToTimeMillisField(duration time.Duration) zapcore.Field
- func FromContext(ctx context.Context) *zap.Logger
- func ServerFilter(opts ...Option) filter.ServerFilter
- func SetLogger(l *zap.Logger)
- type CodeToLevel
- type Decider
- type DurationToField
- type ErrorToCode
- type MessageProducer
- type Option
Constants ¶
This section is empty.
Variables ¶
var DefaultDurationToField = DurationToTimeMillisField
Functions ¶
func ClientFilter ¶
func ClientFilter(opts ...Option) filter.ClientFilter
ClientFilter get client filters
func ContextWith ¶
ContextWith set logger to ctx
func DefaultCodeToLevel ¶
DefaultCodeToLevel code转换为zap level
func DefaultDeciderMethod ¶
DefaultDeciderMethod ...
func DefaultErrorToCode ¶
DefaultErrorToCode default error code function
func DefaultMessageProducer ¶
func DefaultMessageProducer(ctx context.Context, msg string, level zapcore.Level, code int, err error, duration zapcore.Field)
DefaultMessageProducer default message producer
func DurationToTimeMillisField ¶
DurationToTimeMillisField convert time.Duration to zap Field
func FromContext ¶
FromContext get logger from ctx
func ServerFilter ¶
func ServerFilter(opts ...Option) filter.ServerFilter
ServerFilter get server filters
Types ¶
type CodeToLevel ¶
type ErrorToCode ¶
type MessageProducer ¶
type Option ¶
type Option func(*options)
func WithCodes ¶
func WithCodes(f ErrorToCode) Option
WithCodes customizes the function for mapping errors to error codes.
func WithDecider ¶
WithDecider customizes the function for deciding if the gRPC interceptor logs should log.
func WithDurationField ¶
func WithDurationField(f DurationToField) Option
WithDurationField customizes the function for mapping request durations to Zap fields.
func WithLevels ¶
func WithLevels(f CodeToLevel) Option
WithLevels customizes the function for mapping gRPC return codes and interceptor log level statements.
func WithMessageProducer ¶
func WithMessageProducer(f MessageProducer) Option
WithMessageProducer customizes the function for message formation.