logger

package
v0.0.0-...-726a85d Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLevel the default log level
	DefaultLevel = zapcore.InfoLevel

	// DefaultTimeLayout the default time layout;
	DefaultTimeLayout = time.RFC3339
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...zap.Field)

func Error

func Error(msg string, fields ...zap.Field)

func Info

func Info(msg string, fields ...zap.Field)

func InitLoggers

func InitLoggers(opts ...Option) error

func NewJSONLogger

func NewJSONLogger(opts ...Option) (*zap.Logger, error)

NewJSONLogger return a json-encoder zap logger,

func Sync

func Sync()

Sync calls the underlying Core's Sync method, flushing any buffered log entries. Applications should take care to call Sync before exiting.

func Warn

func Warn(msg string, fields ...zap.Field)

func WrapMeta

func WrapMeta(err error, metas ...Meta) (fields []zap.Field)

WrapMeta wrap meta to zap fields

Types

type Meta

type Meta interface {
	Key() string
	Value() interface{}
	// contains filtered or unexported methods
}

Meta key-value

func NewMeta

func NewMeta(key string, value interface{}) Meta

NewMeta create meat

type Option

type Option func(*option)

Option custom setup conf

func WithDebugLevel

func WithDebugLevel() Option

WithDebugLevel only greater than 'level' will output

func WithDisableConsole

func WithDisableConsole() Option

WithDisableConsole WithEnableConsole write log to os.Stdout or os.Stderr

func WithErrorLevel

func WithErrorLevel() Option

WithErrorLevel only greater than 'level' will output

func WithField

func WithField(key, value string) Option

WithField add some field(s) to log

func WithFileP

func WithFileP(file string) Option

WithFileP write log to some file

func WithFileRotationP

func WithFileRotationP(file string) Option

WithFileRotationP write log to some file with rotation

func WithInfoLevel

func WithInfoLevel() Option

WithInfoLevel only greater than 'level' will output

func WithTimeLayout

func WithTimeLayout(timeLayout string) Option

WithTimeLayout custom time format

func WithWarnLevel

func WithWarnLevel() Option

WithWarnLevel only greater than 'level' will output

type ZapGormLogger

type ZapGormLogger struct {
	LogLevel              gormLogger.LogLevel
	SlowThreshold         time.Duration
	SkipErrRecordNotFound bool
}

func (*ZapGormLogger) Error

func (l *ZapGormLogger) Error(ctx context.Context, msg string, data ...interface{})

func (*ZapGormLogger) Info

func (l *ZapGormLogger) Info(ctx context.Context, msg string, data ...interface{})

func (*ZapGormLogger) LogMode

func (*ZapGormLogger) Trace

func (l *ZapGormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (*ZapGormLogger) Warn

func (l *ZapGormLogger) Warn(ctx context.Context, msg string, data ...interface{})

Jump to

Keyboard shortcuts

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