Documentation ¶
Overview ¶
Package logger 日志专用写入器,可设置是否自动依据日期以及文件大小滚动日志文件
Index ¶
- Constants
- func NewWriter(opt *OptLog) io.Writer
- type Logger
- type NilLogger
- func (l *NilLogger) Debug(msg string)
- func (l *NilLogger) DebugFormat(f string, msg ...interface{})
- func (l *NilLogger) DefaultWriter() io.Writer
- func (l *NilLogger) Error(msg string)
- func (l *NilLogger) ErrorFormat(f string, msg ...interface{})
- func (l *NilLogger) Info(msg string)
- func (l *NilLogger) InfoFormat(f string, msg ...interface{})
- func (l *NilLogger) System(msg string)
- func (l *NilLogger) Warning(msg string)
- func (l *NilLogger) WarningFormat(f string, msg ...interface{})
- type OptLog
- type StdLogger
- func (l *StdLogger) Debug(msg string)
- func (l *StdLogger) DebugFormat(f string, msg ...interface{})
- func (l *StdLogger) DefaultWriter() io.Writer
- func (l *StdLogger) Error(msg string)
- func (l *StdLogger) ErrorFormat(f string, msg ...interface{})
- func (l *StdLogger) Info(msg string)
- func (l *StdLogger) InfoFormat(f string, msg ...interface{})
- func (l *StdLogger) System(msg string)
- func (l *StdLogger) Warning(msg string)
- func (l *StdLogger) WarningFormat(f string, msg ...interface{})
- type Writer
Constants ¶
View Source
const (
// ShortTimeFormat 日志事件戳格式
ShortTimeFormat = "15:04:05.000 "
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger interface { Debug(msg string) Info(msg string) Warning(msg string) Error(msg string) System(msg string) DebugFormat(f string, msg ...interface{}) InfoFormat(f string, msg ...interface{}) WarningFormat(f string, msg ...interface{}) ErrorFormat(f string, msg ...interface{}) DefaultWriter() io.Writer }
Logger 日志接口
type NilLogger ¶
type NilLogger struct{}
NilLogger 空日志
func (*NilLogger) DebugFormat ¶
DebugFormat Debug
func (*NilLogger) DefaultWriter ¶
DefaultWriter 返回日志Writer
func (*NilLogger) ErrorFormat ¶
ErrorFormat Error
func (*NilLogger) InfoFormat ¶
InfoFormat Info
func (*NilLogger) WarningFormat ¶
WarningFormat Warning
type OptLog ¶
type OptLog struct { // Filename 日志文件名,不需要扩展名,会自动追加时间戳以及.log扩展名,为空时其他参数无效,仅输出到控制台 Filename string // FileDir 日志存放目录 FileDir string // AutoRoll 是否自动滚动日志文件,true-依据MaxDays和MaxSize自动切分日志文件,日志文件名会额外追加日期时间戳‘yymmdd’和序号 AutoRoll bool // MaxDays 日志最大保留天数,AutoRoll==true时有效 MaxDays int // MaxSize 单个日志文件最大大小,AutoRoll==true时有效 MaxSize int64 // ZipFile 是否压缩旧日志文件,AutoRoll==true时有效 ZipFile bool // SyncToConsole 同步输出到控制台 SyncToConsole bool // DelayWrite 延迟写入,每秒检查写入缓存,并写入文件,非实时写入 DelayWrite bool }
OptLog OptLog
type StdLogger ¶
type StdLogger struct {
// contains filtered or unexported fields
}
StdLogger mx log
func (*StdLogger) DebugFormat ¶
DebugFormat writelog with level 10
func (*StdLogger) ErrorFormat ¶
ErrorFormat writelog with level 40
func (*StdLogger) InfoFormat ¶
InfoFormat writelog with level 20
func (*StdLogger) WarningFormat ¶
WarningFormat writelog with level 30
Click to show internal directories.
Click to hide internal directories.