Documentation ¶
Index ¶
- Variables
- func ContextWithLogger(ctx context.Context, logger *zerolog.Logger) context.Context
- func GetLogger(ctx context.Context) (*zerolog.Logger, error)
- func MustGetLogger(ctx context.Context) *zerolog.Logger
- type Option
- func WithLogErrors(logging bool) Option
- func WithLogRequests(logging bool) Option
- func WithLogger(logger *zerolog.Logger) Option
- func WithProvideRequestFieldsToLogger(provideFields bool) Option
- func WithRequestValueModifier(modifier RequestValueModifier) Option
- func WithUseRequestId(useRequestId bool) Option
- type Options
- type RequestValueModifier
- type ZerologGrpcProvider
Constants ¶
This section is empty.
Variables ¶
var ErrFailedToCastProtoMessage = errors.New("failed to cast proto message into map")
Functions ¶
func ContextWithLogger ¶
Types ¶
type Option ¶
func WithLogErrors ¶
When logging errors is true, the logger will print errors after request completion. Default value is true
func WithLogRequests ¶
When logging is true, the logger will print messages by self into zerolog output. Default value is true
func WithLogger ¶
WithLogger changes the default zerolog logger
func WithProvideRequestFieldsToLogger ¶
When provideFields is enabled, provider will add into zerolog context some request fields Like grpcMethod, grpcServer information etc.
func WithRequestValueModifier ¶
func WithRequestValueModifier(modifier RequestValueModifier) Option
Add request value modifier for modifying request values before they are sent to the output
func WithUseRequestId ¶
When use request id is enabled, interceptor will generate a request identifier in the UUID format and will add this into zerolog context fields list
type RequestValueModifier ¶
Function receiving key and value from the request and returns new value You can use if, for example, for hiding sensitive information from the output Example:
func(key string, value any) (any, error) { if key == "password" { return "<sensitive_data", nil } return value, nil }
type ZerologGrpcProvider ¶
type ZerologGrpcProvider interface { // UnaryInterceptor returns interceptor compatible with grpc api for provide zerolog logger UnaryInterceptor() grpc.UnaryServerInterceptor // StreamInterceptor returns interceptor compatible with grpc api for provide zerolog logger StreamInterceptor() grpc.StreamServerInterceptor // WithModifiers returns object for customizing zerolog logger WithModifiers() *loggerModifiers }
func New ¶
func New(opts ...Option) (ZerologGrpcProvider, error)