logger

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 3 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandle

func AddHandle(ctx context.Context, handle Handle)

func Debug

func Debug(ctx context.Context, msg string, fields ...zap.Field)

func Error

func Error(ctx context.Context, msg string, err error, fields ...zap.Field)

func Fatal

func Fatal(ctx context.Context, msg string, err error, fields ...zap.Field)

func Info

func Info(ctx context.Context, msg string, fields ...zap.Field)

func Notice

func Notice(ctx context.Context, msg string, fields ...zap.Field)

func SetLogger

func SetLogger(l Logger)

SetLogger set global logger

func Trace

func Trace(ctx context.Context, msg string, fields ...zap.Field)

func Warning

func Warning(ctx context.Context, msg string, err error, fields ...zap.Field)

func WithField

func WithField(key string, value interface{}) zap.Field

Types

type Handle

type Handle func(ctx context.Context, lvl Level, msg string, err error, fields ...zap.Field) []zap.Field

type Level added in v0.2.0

type Level interface {
	Code() int
	String() string
}
var (
	LevelFatal  Level = &level{code: 0, name: "fatal"}
	LevelError  Level = &level{code: 1, name: "error"}
	LevelWarn   Level = &level{code: 2, name: "warn"}
	LevelInfo   Level = &level{code: 3, name: "info"}
	LevelNotice Level = &level{code: 4, name: "notice"}
	LevelDebug  Level = &level{code: 5, name: "debug"}
	LevelTrace  Level = &level{code: 6, name: "trace"}
)

func GetLevelByCode added in v0.2.0

func GetLevelByCode(code int) Level

func GetLevelByName added in v0.2.0

func GetLevelByName(name string) Level

type Logger

type Logger interface {
	Fatal(ctx context.Context, msg string, err error, fields ...zap.Field)

	Error(ctx context.Context, msg string, err error, fields ...zap.Field)

	Warning(ctx context.Context, msg string, err error, fields ...zap.Field)

	Info(ctx context.Context, msg string, fields ...zap.Field)

	Notice(ctx context.Context, msg string, fields ...zap.Field)

	Debug(ctx context.Context, msg string, fields ...zap.Field)

	Trace(ctx context.Context, msg string, fields ...zap.Field)

	SetLevel(Level)

	Handle(ctx context.Context, handle Handle)
}

func NewLogger

func NewLogger(ctx context.Context, l *zap.Logger) Logger

Jump to

Keyboard shortcuts

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