log

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Current zlog
	Normal  Logger
)

Functions

func Debug

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

filed可以用zap.Int()等创建

func Debugf

func Debugf(msg string, value ...any)

info 比上面的方法慢一倍,热点代码不建议用

func DevPanic

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

如果是开发模式,则抛出异常

func DevPanicf

func DevPanicf(msg string, fields ...any)

func Error

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

error filed可以用zap.Int()等创建

func Errorf

func Errorf(msg string, fields ...any)

比上面的方法慢一倍,热点代码不建议用

func Info

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

filed可以用zap.Int()等创建

func Infof

func Infof(msg string, value ...any)

比上面的方法慢一倍,热点代码不建议用

func InitLog

func InitLog(level string) error

func InitWithConfig added in v0.0.5

func InitWithConfig(config LogConfig) error

func NewLogger deprecated added in v0.0.9

func NewLogger(config LogConfig) (*zap.Logger, error)

Deprecated: use NewZapLogger instead

func NewZapLogger added in v0.2.20

func NewZapLogger(config LogConfig) (*zap.Logger, error)

new zap logger

func Panic

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

func Panicf

func Panicf(msg string, fields ...any)

func Sync added in v0.0.7

func Sync() error

func Warn

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

warn filed可以用zap.Int()等创建

func Warnf

func Warnf(msg string, fields ...any)

比上面的方法慢一倍,热点代码不建议用

Types

type LogConfig added in v0.0.5

type LogConfig struct {
	Sync       bool   `json:"sync" yaml:"sync"`             // 启用同步模式
	Path       string `json:"path" yaml:"path"`             // 日志输出路径
	MergeError bool   `json:"mergeErr" yaml:"mergeErr"`     // 合并错误日志到常规日志
	ErrPath    string `json:"errPath" yaml:"errPath"`       // 错误日志输出路径
	Console    bool   `json:"console" yaml:"console"`       // 输出到控制台
	NotToFile  bool   `json:"file" yaml:"file"`             // 输出到文件
	Level      string `json:"level" yaml:"level"`           // 日志级别
	Dev        bool   `json:"dev" yaml:"dev"`               // 开发模式
	Caller     bool   `json:"caller" yaml:"caller"`         // 输出调用者信息
	CallerSkip int    `json:"callerSkip" yaml:"callerSkip"` // 跳过调用者代码层级(适用于封装层)
	// contains filtered or unexported fields
}

type LogNormalLevel

type LogNormalLevel struct {
	Level         zapcore.Level
	MergeErrorLog bool
}

func (LogNormalLevel) Enabled

func (e LogNormalLevel) Enabled(lvl zapcore.Level) bool

type Logger added in v0.2.0

type Logger interface {
	Debug(v ...any)
	Info(v ...any)
	Warn(v ...any)
	Error(v ...any)
	Debugf(format string, v ...any)
	Infof(format string, v ...any)
	Warnf(format string, v ...any)
	Errorf(format string, v ...any)
}

func NewNormalLogger added in v0.2.20

func NewNormalLogger(config LogConfig) (Logger, error)

new logger

Jump to

Keyboard shortcuts

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