logger

package
v0.0.6-beta Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = NewLogger(
	zap.NewExample().WithOptions(zap.Development()).With(zap.Bool("default", true)),
)

Functions

func AddLogFields

func AddLogFields(ctx context.Context, fields ...zap.Field)

func AppendField

func AppendField(zapFields []zapcore.Field, key string, value string) []zapcore.Field

func AppendZapField

func AppendZapField(zapFields []zapcore.Field, field zapcore.Field) []zapcore.Field

func RpcLogger

func RpcLogger(extractor Extractor) grpc.UnaryServerInterceptor

func WithLogger

func WithLogger(ctx context.Context, logger Logger) context.Context

Types

type ContextLogger

type ContextLogger struct {
	Logger Logger
	Fields []zap.Field
}

func NewContextLogger

func NewContextLogger(logger Logger, fields ...zap.Field) *ContextLogger

func NewLogger

func NewLogger(logger *zap.Logger, logFields ...zap.Field) *ContextLogger

func (*ContextLogger) AddFields

func (ctxLogger *ContextLogger) AddFields(fields ...zap.Field)

func (*ContextLogger) Debug

func (ctxLogger *ContextLogger) Debug(msg string, fields ...zap.Field)

func (*ContextLogger) Error

func (ctxLogger *ContextLogger) Error(msg string, fields ...zap.Field)

func (*ContextLogger) Fatal

func (ctxLogger *ContextLogger) Fatal(msg string, fields ...zap.Field)

func (*ContextLogger) Info

func (ctxLogger *ContextLogger) Info(msg string, fields ...zap.Field)

func (*ContextLogger) Panic

func (ctxLogger *ContextLogger) Panic(msg string, fields ...zap.Field)

func (*ContextLogger) Warn

func (ctxLogger *ContextLogger) Warn(msg string, fields ...zap.Field)

type Error

type Error struct {
	UserError     error
	InternalError error
}

func RpcError

func RpcError(user, internal error) *Error

func (*Error) Error

func (e *Error) Error() string

type Extractor

type Extractor func(resp interface{}, err error, code codes.Code) string

type Logger

type Logger interface {
	AddFields(fields ...zap.Field)

	Panic(msg string, fields ...zap.Field)
	Fatal(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
	Warn(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Debug(msg string, fields ...zap.Field)
}

func Log

func Log(ctx context.Context) Logger

Jump to

Keyboard shortcuts

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