Documentation ¶
Index ¶
- Constants
- func Flush()
- func GinLogger(skipPaths []string) gin.HandlerFunc
- func GinRecovery() gin.HandlerFunc
- type FileOutputOpt
- type Level
- type Logger
- func Debug(msg string, vs ...any) *Logger
- func Error(vs ...any) *Logger
- func Info(msg string, vs ...any) *Logger
- func New(opts ...LoggerOption) *Logger
- func NewFileOutput(opts ...FileOutputOpt) *Logger
- func NewOutput(writer io.Writer) *Logger
- func SetLogger(logger *Logger) *Logger
- func SetLv(lv Level) *Logger
- func Warn(msg string, vs ...any) *Logger
- func With(k string, v any) *Logger
- func (l *Logger) AddCore(core ...zapcore.Core)
- func (l *Logger) Debug(msg string, vs ...any)
- func (l *Logger) Error(vs ...any)
- func (l *Logger) Flush()
- func (l *Logger) Info(msg string, vs ...any)
- func (l *Logger) Lv() Level
- func (l *Logger) NewFileOutput(opts ...FileOutputOpt)
- func (l *Logger) NewOutput(writer io.Writer)
- func (l *Logger) SetLv(lv Level)
- func (l *Logger) Warn(msg string, vs ...any)
- func (l *Logger) With(k string, v any) *Logger
- type LoggerOption
Constants ¶
View Source
const ( DebugLv = Level(zapcore.DebugLevel) InfoLv = Level(zapcore.InfoLevel) WarnLv = Level(zapcore.WarnLevel) ErrorLv = Level(zapcore.ErrorLevel) )
Variables ¶
This section is empty.
Functions ¶
func GinLogger ¶ added in v0.4.0
func GinLogger(skipPaths []string) gin.HandlerFunc
func GinRecovery ¶ added in v0.4.0
func GinRecovery() gin.HandlerFunc
Types ¶
type FileOutputOpt ¶ added in v0.5.1
type FileOutputOpt func(*outFileConfig)
FileOutputOpt 文件输出选项
func WithCompress ¶ added in v0.5.1
func WithCompress(compress bool) FileOutputOpt
func WithFilename ¶ added in v0.5.1
func WithFilename(filename string) FileOutputOpt
func WithLocalTime ¶ added in v0.5.1
func WithLocalTime(localTime bool) FileOutputOpt
func WithMaxAge ¶ added in v0.5.1
func WithMaxAge(maxAge int) FileOutputOpt
func WithMaxBackups ¶ added in v0.5.1
func WithMaxBackups(maxBackups int) FileOutputOpt
func WithMaxSize ¶ added in v0.5.1
func WithMaxSize(maxSize int) FileOutputOpt
type Logger ¶ added in v0.5.1
type Logger struct { // 日志打印用 Logger zap.SugaredLogger // contains filtered or unexported fields }
Logger 是对 zap.SugaredLogger 的封装,简化其对外使用的接口, 并且针对于 Logger 所有配置都是支持运行时动态修改,且并发安全。 Logger 也支持了针对于 zapcore.Core 的扩展,调用 Logger.AddCore 即可,
构建该对象请使用 New 进行创建,在该操作中会对部分必要属性进行初始化, 直接使用结构体创建会导致结构体不可用(甚至panic)。
如非深度定制化扩展,非必要不建议使用 Logger.AddCore 进行扩展,该操作会 导致客户端应用程序对zap包编译依赖,不保证fslog切换内部日志实现。
var Log *Logger
func New ¶ added in v0.5.5
func New(opts ...LoggerOption) *Logger
func NewFileOutput ¶ added in v0.5.1
func NewFileOutput(opts ...FileOutputOpt) *Logger
NewFileOutput 见 Logger.NewFileOutput
func (*Logger) Error ¶ added in v0.5.1
Error 打印错误级别日志 该方法具有两种传参形式:
- error类型:会直接格式化打印%+v日志
- 信息(格式化)
- error+格式化信息:error会作为 With 格式存在,且依旧以%+v格式输出
func (*Logger) NewFileOutput ¶ added in v0.5.1
func (l *Logger) NewFileOutput(opts ...FileOutputOpt)
NewFileOutput 新增日志输出文件配置
type LoggerOption ¶ added in v0.5.7
type LoggerOption func(*loggerConfig)
func WithSkipCaller ¶ added in v0.5.7
func WithSkipCaller(skip int) LoggerOption
Click to show internal directories.
Click to hide internal directories.