logger

package
v3.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLevel = zap.InfoLevel
	DefaultLog   = func(level zapcore.Level, msg string, fields ...zap.Field) {
		line, _ := EncodeFields(DefaultJsonEncoder, level, msg, fields...)
		if len(line) > 0 {
			fmt.Println(bytes2String(line))
		}
	}
)
View Source
var (
	DefaultJsonEncoder = zapcore.NewJSONEncoder(
		zapcore.EncoderConfig{
			MessageKey: "Message",
			LevelKey:   "Level",
			TimeKey:    "DateTime",
			EncodeTime: func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
				enc.AppendString(t.Format("2006-01-02 15:04:05"))
			},
			EncodeLevel:  zapcore.CapitalLevelEncoder,
			CallerKey:    "File",
			EncodeCaller: zapcore.ShortCallerEncoder,
		},
	)
)

Functions

func Debug

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

func EncodeFields

func EncodeFields(encoder zapcore.Encoder, level zapcore.Level, msg string, fields ...zapcore.Field) ([]byte, error)

func Error

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

func Info

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

func IsDebug

func IsDebug() bool

func NewZapLoggerWithLumberjack added in v3.0.12

func NewZapLoggerWithLumberjack(basePath string, enc zapcore.Encoder, ljOption *lumberjack.Logger) *zap.Logger

func Warn

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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