logger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package logger logger/console_encoder.go

Index

Constants

This section is empty.

Variables

View Source
var Logger *zap.Logger

Logger 全局日志实例

Functions

func Debug

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

func Error

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

func ErrorAndExit

func ErrorAndExit(msg string, err error)

ErrorAndExit @Description 报错并退出应用(非常危险!) @Author CuratorC 2026-03-18 11:18:19 @Param msg @Param err

func ErrorErr

func ErrorErr(msg string, err error)

func Info

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

func LogIf

func LogIf(err error, fields ...zap.Field)

LogIf @Description 非空 err 时记录 Error 级别日志并附带调用栈 @Param err error @Param fields ...zap.Field 额外的日志字段

func NewFancyEncoder

func NewFancyEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder

NewFancyEncoder @Description 创建美化控制台编码器 @Author CuratorC 2026-03-19 10:31:00 @Param cfg zapcore.EncoderConfig @Return zapcore.Encoder

func SetupLogger

func SetupLogger(configPath string) (err error)

SetupLogger 初始化日志

func Warn

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

Types

type FancyEncoder

type FancyEncoder struct {
	zapcore.EncoderConfig
}

FancyEncoder @Description 美化的控制台日志编码器 @Author CuratorC 2026-03-19 10:31:00

func (*FancyEncoder) AddArray

func (e *FancyEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) error

func (*FancyEncoder) AddBinary

func (e *FancyEncoder) AddBinary(key string, value []byte)

func (*FancyEncoder) AddBool

func (e *FancyEncoder) AddBool(key string, value bool)

func (*FancyEncoder) AddByteString

func (e *FancyEncoder) AddByteString(key string, value []byte)

func (*FancyEncoder) AddComplex64

func (e *FancyEncoder) AddComplex64(key string, value complex64)

func (*FancyEncoder) AddComplex128

func (e *FancyEncoder) AddComplex128(key string, value complex128)

func (*FancyEncoder) AddDuration

func (e *FancyEncoder) AddDuration(key string, value time.Duration)

func (*FancyEncoder) AddFloat32

func (e *FancyEncoder) AddFloat32(key string, value float32)

func (*FancyEncoder) AddFloat64

func (e *FancyEncoder) AddFloat64(key string, value float64)

func (*FancyEncoder) AddInt

func (e *FancyEncoder) AddInt(key string, value int)

func (*FancyEncoder) AddInt8

func (e *FancyEncoder) AddInt8(key string, value int8)

func (*FancyEncoder) AddInt16

func (e *FancyEncoder) AddInt16(key string, value int16)

func (*FancyEncoder) AddInt32

func (e *FancyEncoder) AddInt32(key string, value int32)

func (*FancyEncoder) AddInt64

func (e *FancyEncoder) AddInt64(key string, value int64)

func (*FancyEncoder) AddObject

func (e *FancyEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) error

func (*FancyEncoder) AddReflected

func (e *FancyEncoder) AddReflected(key string, value interface{}) error

func (*FancyEncoder) AddString

func (e *FancyEncoder) AddString(key string, value string)

func (*FancyEncoder) AddTime

func (e *FancyEncoder) AddTime(key string, value time.Time)

func (*FancyEncoder) AddUint

func (e *FancyEncoder) AddUint(key string, value uint)

func (*FancyEncoder) AddUint8

func (e *FancyEncoder) AddUint8(key string, value uint8)

func (*FancyEncoder) AddUint16

func (e *FancyEncoder) AddUint16(key string, value uint16)

func (*FancyEncoder) AddUint32

func (e *FancyEncoder) AddUint32(key string, value uint32)

func (*FancyEncoder) AddUint64

func (e *FancyEncoder) AddUint64(key string, value uint64)

func (*FancyEncoder) AddUintptr

func (e *FancyEncoder) AddUintptr(key string, value uintptr)

func (*FancyEncoder) Clone

func (e *FancyEncoder) Clone() zapcore.Encoder

func (*FancyEncoder) EncodeEntry

func (e *FancyEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)

func (*FancyEncoder) OpenNamespace

func (e *FancyEncoder) OpenNamespace(key string)

Jump to

Keyboard shortcuts

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