Documentation
¶
Index ¶
- type FastLog
- func (l *FastLog) Close()
- func (l *FastLog) Debug(v ...interface{})
- func (l *FastLog) Debugf(format string, v ...interface{})
- func (l *FastLog) Error(v ...interface{})
- func (l *FastLog) Errorf(format string, v ...interface{})
- func (l *FastLog) Info(v ...interface{})
- func (l *FastLog) Infof(format string, v ...interface{})
- func (l *FastLog) Success(v ...interface{})
- func (l *FastLog) Successf(format string, v ...interface{})
- func (l *FastLog) Warn(v ...interface{})
- func (l *FastLog) Warnf(format string, v ...interface{})
- type FastLogConfig
- type FastLogInterface
- type LogFormatType
- type LogLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FastLog ¶ added in v1.1.3
type FastLog struct {
// contains filtered or unexported fields
}
日志记录器
type FastLogConfig ¶ added in v1.1.3
type FastLogConfig struct { LogDirName string // 日志目录名称 LogFileName string // 日志文件名称 LogPath string // 日志文件路径 内部拼接的 [logDirName+logFileName] 无需提供 PrintToConsole bool // 是否将日志输出到控制台 ConsoleOnly bool // 是否仅输出到控制台 LogLevel LogLevel // 日志级别 ChanIntSize int // 通道大小 BufferKbSize int // 缓冲区大小 LogFormat LogFormatType // 日志格式选项 [ Json(json格式) | Bracket(括号格式) | Detailed(详细格式) | Threaded(协程格式) ] EnableLogRotation bool // 是否启用日志切割 [true|false] 默认false LogRetentionDays int // 日志保留天数 默认7天 单位[天] LogMaxSize string // 日志文件最大大小 默认3MB 单位[KB|MB|GB] LogRetentionCount int // 日志文件保留数量 默认3 单位[个] EnableCompression bool // 是否启用日志压缩 [true|false] RotationInterval int // 日志轮转的间隔时间 默认10分钟 单位[秒] CompressionFormat string // 日志压缩格式 [ zip | gz | tar | tgz ] 默认zip }
日志配置
func NewConfig ¶ added in v1.1.0
func NewConfig(logDirName string, logFileName string) *FastLogConfig
创建一个新的日志配置器
type FastLogInterface ¶ added in v1.1.3
type FastLogInterface interface { Info(v ...interface{}) // 记录信息级别的日志,不支持占位符,需要自己拼接 Warn(v ...interface{}) // 记录警告级别的日志,不支持占位符,需要自己拼接 Error(v ...interface{}) // 记录错误级别的日志,不支持占位符,需要自己拼接 Success(v ...interface{}) // 记录成功级别的日志,不支持占位符,需要自己拼接 Debug(v ...interface{}) // 记录调试级别的日志,不支持占位符,需要自己拼接 Close() // 关闭日志记录器 Infof(format string, v ...interface{}) // 记录信息级别的日志,支持占位符,格式化 Warnf(format string, v ...interface{}) // 记录警告级别的日志,支持占位符,格式化 Errorf(format string, v ...interface{}) // 记录错误级别的日志,支持占位符,格式化 Successf(format string, v ...interface{}) // 记录成功级别的日志,支持占位符,格式化 Debugf(format string, v ...interface{}) // 记录调试级别的日志,支持占位符,格式化 }
定义一个接口, 声明对外暴露的方法
type LogFormatType ¶ added in v1.1.0
type LogFormatType int
const ( // 日志格式选项 Detailed LogFormatType = iota // 详细格式 Bracket // 方括号格式 Json // json格式 Threaded // 协程格式 )
func (LogFormatType) String ¶ added in v1.1.2
func (lft LogFormatType) String() string
String 方法,将 LogFormatType 转换为字符串
Click to show internal directories.
Click to hide internal directories.