zaplogs

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDurationToField = DurationToTimeMillisField

Functions

func ClientFilter

func ClientFilter(opts ...Option) filter.ClientFilter

ClientFilter get client filters

func ContextWith

func ContextWith(ctx context.Context, logger *zap.Logger) context.Context

ContextWith set logger to ctx

func DefaultCodeToLevel

func DefaultCodeToLevel(code int) zapcore.Level

DefaultCodeToLevel code转换为zap level

func DefaultDeciderMethod

func DefaultDeciderMethod(fullMethodName string, err error) bool

DefaultDeciderMethod ...

func DefaultErrorToCode

func DefaultErrorToCode(err error) int

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

func DurationToTimeMillisField(duration time.Duration) zapcore.Field

DurationToTimeMillisField convert time.Duration to zap Field

func FromContext

func FromContext(ctx context.Context) *zap.Logger

FromContext get logger from ctx

func ServerFilter

func ServerFilter(opts ...Option) filter.ServerFilter

ServerFilter get server filters

func SetLogger

func SetLogger(l *zap.Logger)

SetLogger set logger

Types

type CodeToLevel

type CodeToLevel func(code int) zapcore.Level

type Decider

type Decider func(fullMethodName string, err error) bool

type DurationToField

type DurationToField func(duration time.Duration) zapcore.Field

type ErrorToCode

type ErrorToCode func(err error) int

type MessageProducer

type MessageProducer func(ctx context.Context, msg string, level zapcore.Level,
	code int, err error, duration zapcore.Field)

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

func WithDecider(f Decider) Option

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL