log

package
v0.0.0-...-e348a8d Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Skip        = zap.Skip
	Binary      = zap.Binary
	Bool        = zap.Bool
	BoolP       = zap.Boolp
	ByteString  = zap.ByteString
	Complex128  = zap.Complex128
	Complex128P = zap.Complex128p
	Complex64   = zap.Complex64
	Complex64P  = zap.Complex64p
	Float64     = zap.Float64
	Float64P    = zap.Float64p
	Float32     = zap.Float32
	Float32P    = zap.Float32p
	Int         = zap.Int
	IntP        = zap.Intp
	Int64       = zap.Int64
	Int64P      = zap.Int64p
	Int32       = zap.Int32
	Int32P      = zap.Int32p
	Int16       = zap.Int16
	Int16P      = zap.Int16p
	Int8        = zap.Int8
	Int8P       = zap.Int8p
	String      = zap.String
	StringP     = zap.Stringp
	Uint        = zap.Uint
	UintP       = zap.Uintp
	Uint64      = zap.Uint64
	Uint64P     = zap.Uint64p
	Uint32      = zap.Uint32
	Uint32P     = zap.Uint32p
	Uint16      = zap.Uint16
	Uint16P     = zap.Uint16p
	Uint8       = zap.Uint8
	Uint8P      = zap.Uint8p
	Uintptr     = zap.Uintptr
	UintptrP    = zap.Uintptrp
	Reflect     = zap.Reflect
	Namespace   = zap.Namespace
	Stringer    = zap.Stringer
	Time        = zap.Time
	TimeP       = zap.Timep
	Stack       = zap.Stack
	StackSkip   = zap.StackSkip
	Duration    = func(key string, val time.Duration) Field { return String(key, val.String()) }
	DurationP   = func(key string, val *time.Duration) Field { str := (*val).String(); return StringP(key, &str) }
	Object      = zap.Object
	Inline      = zap.Inline
	Any         = zap.Any
	Err         = zap.Error
)

Functions

func DPanic

func DPanic(msg string, fields ...Field)

func DPanicf

func DPanicf(format string, args ...any)

func Debug

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

func Debugf

func Debugf(format string, args ...any)

func Error

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

func Errorf

func Errorf(format string, args ...any)

func Fatal

func Fatal(msg string, fields ...Field)

func Fatalf

func Fatalf(format string, args ...any)

func Info

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

func Infof

func Infof(format string, args ...any)

func Panic

func Panic(msg string, fields ...Field)

func Panicf

func Panicf(format string, args ...any)

func SetLogger

func SetLogger(log Logger)

func Warn

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

func Warnf

func Warnf(format string, args ...any)

Types

type Core

type Core = zapcore.Core

type Encoder

type Encoder = zapcore.Encoder

func NewEncoder

func NewEncoder() Encoder

type Field

type Field = zap.Field

type Level

type Level = zapcore.Level
const (
	DebugLevel  Level = zapcore.DebugLevel
	InfoLevel   Level = zapcore.InfoLevel
	WarnLevel   Level = zapcore.WarnLevel
	ErrorLevel  Level = zapcore.ErrorLevel
	DPanicLevel Level = zapcore.DPanicLevel
	PanicLevel  Level = zapcore.PanicLevel
	FatalLevel  Level = zapcore.FatalLevel
)

func Levels

func Levels() []Level

type LevelEnablerFunc

type LevelEnablerFunc = zap.LevelEnablerFunc

func DPanicLevelPartition

func DPanicLevelPartition() LevelEnablerFunc

func DebugLevelPartition

func DebugLevelPartition() LevelEnablerFunc

func ErrorLevelPartition

func ErrorLevelPartition() LevelEnablerFunc

func FatalLevelPartition

func FatalLevelPartition() LevelEnablerFunc

func InfoLevelPartition

func InfoLevelPartition() LevelEnablerFunc

func PanicLevelPartition

func PanicLevelPartition() LevelEnablerFunc

func WarnLevelPartition

func WarnLevelPartition() LevelEnablerFunc

type Log

type Log struct {
	// contains filtered or unexported fields
}

func NewLog

func NewLog(options ...Option) *Log

func (*Log) DPanic

func (slf *Log) DPanic(msg string, fields ...Field)

DPanic 仅在开发模式下Panic

func (*Log) DPanicf

func (slf *Log) DPanicf(format string, args ...any)

func (*Log) Debug

func (slf *Log) Debug(msg string, fields ...Field)

func (*Log) Debugf

func (slf *Log) Debugf(format string, args ...any)

func (*Log) Error

func (slf *Log) Error(msg string, fields ...Field)

func (*Log) Errorf

func (slf *Log) Errorf(format string, args ...any)

func (*Log) Fatal

func (slf *Log) Fatal(msg string, fields ...Field)

func (*Log) Fatalf

func (slf *Log) Fatalf(format string, args ...any)

func (*Log) Info

func (slf *Log) Info(msg string, fields ...Field)

func (*Log) Infof

func (slf *Log) Infof(format string, args ...any)

func (*Log) Panic

func (slf *Log) Panic(msg string, fields ...Field)

func (*Log) Panicf

func (slf *Log) Panicf(format string, args ...any)

func (*Log) Warn

func (slf *Log) Warn(msg string, fields ...Field)

func (*Log) Warnf

func (slf *Log) Warnf(format string, args ...any)

type Logger

type Logger interface {
	Debug(msg string, fields ...Field)
	Info(msg string, fields ...Field)
	Warn(msg string, fields ...Field)
	Error(msg string, fields ...Field)
	DPanic(msg string, fields ...Field)
	Panic(msg string, fields ...Field)
	Fatal(msg string, fields ...Field)
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(format string, args ...any)
	DPanicf(format string, args ...any)
	Panicf(format string, args ...any)
	Fatalf(format string, args ...any)
	// contains filtered or unexported methods
}

func GetLogger

func GetLogger() Logger

type Option

type Option func(log *Log)

func WithFilename

func WithFilename(filename func(level Level) string) Option

WithFilename 设置日志文件名,默认为:{level}.log

func WithLogDir

func WithLogDir(logDir, rotateLogDir string) Option

WithLogDir 设置日志存储目录,若为空则不会存储文件

func WithRotateFilename

func WithRotateFilename(filename func(level Level) string) Option

WithRotateFilename 设置日志分割文件名,默认为:{level}.%Y%m%d.log

func WithRotateOption

func WithRotateOption(options ...rotatelogs.Option) Option

WithRotateOption 设置日志分割选项,默认选项为:WithMaxAge(time.Hour*24*7),WithRotationTime(time.Hour*24)

func WithRunMode

func WithRunMode(mode RunMode, handle func() Core) Option

WithRunMode 设置运行模式,默认为:RunModeDev

type RunMode

type RunMode = uint8
const (
	RunModeDev  RunMode = iota
	RunModeTest RunMode = iota
	RunModeProd RunMode = iota
)

Jump to

Keyboard shortcuts

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