Documentation
¶
Index ¶
- type FileConfig
- type Level
- type Logger
- type Option
- type ZeroLogger
- func (l *ZeroLogger) Debug(msg string, fields ...any)
- func (l *ZeroLogger) Err(err error, msg string, fields ...any)
- func (l *ZeroLogger) Error(msg string, fields ...any)
- func (l *ZeroLogger) Info(msg string, fields ...any)
- func (l *ZeroLogger) Log(level Level, msg string, fields ...any)
- func (l *ZeroLogger) Warn(msg string, fields ...any)
- func (l ZeroLogger) With(fields ...any) Logger
- func (l *ZeroLogger) WithContext(ctx context.Context) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileConfig ¶
type FileConfig struct {
Path string
Filename string
MaxSize int
MaxAge int
MaxBackups int
Compress bool
LocalTime bool
}
FileConfig 文件日志配置
type Logger ¶
type Logger interface {
// Info 记录 Info 级别日志
Info(msg string, fields ...any)
// Error 记录 Error 级别日志
Error(msg string, fields ...any)
// Debug 记录 Debug 级别日志
Debug(msg string, fields ...any)
// Warn 记录 Warn 级别日志
Warn(msg string, fields ...any)
// Err 封装 Error 错误
Err(err error, msg string, fields ...any)
// Log 指定级别记录日志
Log(level Level, msg string, fields ...any)
// WithContext 将日志实例添加到上下文中
WithContext(ctx context.Context) context.Context
// With 创建新的 Logger
With(fields ...any) Logger
}
Logger 日志接口
type Option ¶
type Option func(*ZeroLogger)
Option 日志组件配置项
func WithFileWithConfig ¶
func WithFileWithConfig(cfg FileConfig) Option
WithFileWithConfig 添加文件写入器(使用自定义配置)
type ZeroLogger ¶
type ZeroLogger struct {
// contains filtered or unexported fields
}
ZeroLogger 日志组件
func (*ZeroLogger) Err ¶
func (l *ZeroLogger) Err(err error, msg string, fields ...any)
Err 记录包含错误信息日志
func (*ZeroLogger) Log ¶
func (l *ZeroLogger) Log(level Level, msg string, fields ...any)
Log 指定级别记录日志
func (*ZeroLogger) WithContext ¶
func (l *ZeroLogger) WithContext(ctx context.Context) context.Context
WithContext 将日志实例添加到上下文中
Click to show internal directories.
Click to hide internal directories.