Documentation ¶
Index ¶
- Constants
- type ConsoleFileLogger
- func (cf *ConsoleFileLogger) Debug(msg string)
- func (cf *ConsoleFileLogger) Debugf(format string, a ...interface{})
- func (cf *ConsoleFileLogger) Error(msg string)
- func (cf *ConsoleFileLogger) Errorf(format string, a ...interface{})
- func (cf *ConsoleFileLogger) Fatal(msg string)
- func (cf *ConsoleFileLogger) Fatalf(format string, a ...interface{})
- func (cf *ConsoleFileLogger) Info(msg string)
- func (cf *ConsoleFileLogger) Infof(format string, a ...interface{})
- func (cf *ConsoleFileLogger) SetEncoder(encode encoder)
- func (cf *ConsoleFileLogger) SetFileInfo(level LogLevel)
- func (cf *ConsoleFileLogger) SetPrefix(prefix string)
- func (cf *ConsoleFileLogger) SetTimeFormat(format string)
- func (cf *ConsoleFileLogger) Trace(msg string)
- func (cf *ConsoleFileLogger) Tracef(format string, a ...interface{})
- func (cf *ConsoleFileLogger) Warning(msg string)
- func (cf *ConsoleFileLogger) Warningf(format string, a ...interface{})
- type ConsoleLogger
- func (cl *ConsoleLogger) Debug(msg string)
- func (cl *ConsoleLogger) Debugf(format string, args ...interface{})
- func (cl *ConsoleLogger) Error(msg string)
- func (cl *ConsoleLogger) Errorf(format string, args ...interface{})
- func (cl *ConsoleLogger) Fatal(msg string)
- func (cl *ConsoleLogger) Fatalf(format string, args ...interface{})
- func (cl *ConsoleLogger) Info(msg string)
- func (cl *ConsoleLogger) Infof(format string, args ...interface{})
- func (cl *ConsoleLogger) JsonEncode(formatTime, fileInfo, level, msg string) []byte
- func (cl *ConsoleLogger) Log(level LogLevel, format string, args ...interface{})
- func (cl *ConsoleLogger) SetEncoder(encode encoder)
- func (cl *ConsoleLogger) SetFileInfo(level LogLevel)
- func (cl *ConsoleLogger) SetPrefix(prefix string)
- func (cl *ConsoleLogger) SetTimeFormat(format string)
- func (cl *ConsoleLogger) TextEncode(formatTime, fileInfo, level, msg string) []byte
- func (cl *ConsoleLogger) Trace(msg string)
- func (cl *ConsoleLogger) Tracef(format string, args ...interface{})
- func (cl *ConsoleLogger) Warning(msg string)
- func (cl *ConsoleLogger) Warningf(format string, args ...interface{})
- type FileLogger
- func (fl *FileLogger) CheckFileCount()
- func (fl *FileLogger) CheckFileMaxAge()
- func (fl *FileLogger) CheckFileSize(file *os.File) bool
- func (fl *FileLogger) CheckSplitFileAge(now time.Time) bool
- func (fl *FileLogger) Debug(msg string)
- func (fl *FileLogger) Debugf(format string, args ...interface{})
- func (fl *FileLogger) Error(msg string)
- func (fl *FileLogger) Errorf(format string, args ...interface{})
- func (fl *FileLogger) Fatal(msg string)
- func (fl *FileLogger) Fatalf(format string, args ...interface{})
- func (fl *FileLogger) Info(msg string)
- func (fl *FileLogger) Infof(format string, args ...interface{})
- func (fl *FileLogger) JsonEncode(logMsg *LogMsg) []byte
- func (fl *FileLogger) Log(level LogLevel, format string, args ...interface{})
- func (fl *FileLogger) RemoveMoreMaxAgeFile(loc *time.Location)
- func (fl *FileLogger) RemoveMoreMaxCountFile(loc *time.Location)
- func (fl *FileLogger) SetEncoder(encode encoder)
- func (fl *FileLogger) SetFileInfo(level LogLevel)
- func (fl *FileLogger) SetPrefix(prefix string)
- func (fl *FileLogger) SetTimeFormat(format string)
- func (fl *FileLogger) TextEncode(logMsg *LogMsg) []byte
- func (fl *FileLogger) Trace(msg string)
- func (fl *FileLogger) Tracef(format string, args ...interface{})
- func (fl *FileLogger) Warning(msg string)
- func (fl *FileLogger) Warningf(format string, args ...interface{})
- type LogLevel
- type LogMsg
- type Logger
- type LogoHandleFunc
- type MaxFileCount
- type OptionFn
Constants ¶
View Source
const ( TextEncoder encoder = iota JsonEncoder )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsoleFileLogger ¶
type ConsoleFileLogger struct {
// contains filtered or unexported fields
}
func NewConsoleFileLogger ¶
func NewConsoleFileLogger(stdout LogLevel, file LogLevel, fp, fn string, options ...LogoHandleFunc) *ConsoleFileLogger
func (*ConsoleFileLogger) Debug ¶
func (cf *ConsoleFileLogger) Debug(msg string)
func (*ConsoleFileLogger) Debugf ¶
func (cf *ConsoleFileLogger) Debugf(format string, a ...interface{})
func (*ConsoleFileLogger) Error ¶
func (cf *ConsoleFileLogger) Error(msg string)
func (*ConsoleFileLogger) Errorf ¶
func (cf *ConsoleFileLogger) Errorf(format string, a ...interface{})
func (*ConsoleFileLogger) Fatal ¶
func (cf *ConsoleFileLogger) Fatal(msg string)
func (*ConsoleFileLogger) Fatalf ¶
func (cf *ConsoleFileLogger) Fatalf(format string, a ...interface{})
func (*ConsoleFileLogger) Info ¶
func (cf *ConsoleFileLogger) Info(msg string)
func (*ConsoleFileLogger) Infof ¶
func (cf *ConsoleFileLogger) Infof(format string, a ...interface{})
func (*ConsoleFileLogger) SetEncoder ¶
func (cf *ConsoleFileLogger) SetEncoder(encode encoder)
func (*ConsoleFileLogger) SetFileInfo ¶
func (cf *ConsoleFileLogger) SetFileInfo(level LogLevel)
func (*ConsoleFileLogger) SetPrefix ¶
func (cf *ConsoleFileLogger) SetPrefix(prefix string)
func (*ConsoleFileLogger) SetTimeFormat ¶
func (cf *ConsoleFileLogger) SetTimeFormat(format string)
func (*ConsoleFileLogger) Trace ¶
func (cf *ConsoleFileLogger) Trace(msg string)
func (*ConsoleFileLogger) Tracef ¶
func (cf *ConsoleFileLogger) Tracef(format string, a ...interface{})
func (*ConsoleFileLogger) Warning ¶
func (cf *ConsoleFileLogger) Warning(msg string)
func (*ConsoleFileLogger) Warningf ¶
func (cf *ConsoleFileLogger) Warningf(format string, a ...interface{})
type ConsoleLogger ¶
type ConsoleLogger struct { Level LogLevel `json:"level"` Prefix string `json:"prefix"` FileInfoLevel LogLevel `json:"file_info_level"` Encoder encoder `json:"encoder"` }
func New ¶
func New() *ConsoleLogger
func NewConsoleLogger ¶
func NewConsoleLogger(level LogLevel, args ...interface{}) *ConsoleLogger
ConsoleLogger 构造函数
func (*ConsoleLogger) Debug ¶
func (cl *ConsoleLogger) Debug(msg string)
func (*ConsoleLogger) Debugf ¶
func (cl *ConsoleLogger) Debugf(format string, args ...interface{})
func (*ConsoleLogger) Error ¶
func (cl *ConsoleLogger) Error(msg string)
func (*ConsoleLogger) Errorf ¶
func (cl *ConsoleLogger) Errorf(format string, args ...interface{})
func (*ConsoleLogger) Fatal ¶
func (cl *ConsoleLogger) Fatal(msg string)
func (*ConsoleLogger) Fatalf ¶
func (cl *ConsoleLogger) Fatalf(format string, args ...interface{})
func (*ConsoleLogger) Info ¶
func (cl *ConsoleLogger) Info(msg string)
func (*ConsoleLogger) Infof ¶
func (cl *ConsoleLogger) Infof(format string, args ...interface{})
func (*ConsoleLogger) JsonEncode ¶
func (cl *ConsoleLogger) JsonEncode(formatTime, fileInfo, level, msg string) []byte
func (*ConsoleLogger) Log ¶
func (cl *ConsoleLogger) Log(level LogLevel, format string, args ...interface{})
func (*ConsoleLogger) SetEncoder ¶
func (cl *ConsoleLogger) SetEncoder(encode encoder)
func (*ConsoleLogger) SetFileInfo ¶
func (cl *ConsoleLogger) SetFileInfo(level LogLevel)
func (*ConsoleLogger) SetPrefix ¶
func (cl *ConsoleLogger) SetPrefix(prefix string)
func (*ConsoleLogger) SetTimeFormat ¶
func (cl *ConsoleLogger) SetTimeFormat(format string)
func (*ConsoleLogger) TextEncode ¶
func (cl *ConsoleLogger) TextEncode(formatTime, fileInfo, level, msg string) []byte
func (*ConsoleLogger) Trace ¶
func (cl *ConsoleLogger) Trace(msg string)
func (*ConsoleLogger) Tracef ¶
func (cl *ConsoleLogger) Tracef(format string, args ...interface{})
func (*ConsoleLogger) Warning ¶
func (cl *ConsoleLogger) Warning(msg string)
func (*ConsoleLogger) Warningf ¶
func (cl *ConsoleLogger) Warningf(format string, args ...interface{})
type FileLogger ¶
type FileLogger struct { // 日志级别 比该级别高的打印的时候会显示 Level LogLevel `json:"level"` // 前缀 打印日志信息的前缀 Prefix string `json:"prefix"` // 日志文件夹路径 FilePath string `json:"file_path"` // 日志文件名 FileName string `json:"file_name"` // 错误日志文件名 ErrFileName string `json:"err_file_name"` // 最大文件大小 分割日志文件的时候会用到 MaxFileSize int64 `json:"max_file_size"` // 最大文件保留个数 MaxFileCount int `json:"max_file_count"` MaxErrFileCount int `json:"max_file_count"` // 分割文件最大时间间隔 按时间分割文件的时候会用到 SplitFileAge int `json:"split_file_age"` // 最大保存保存时间长度 MaxFileAge int `json:"max_file_age"` // 是否打印文件行号信息 FileInfoLevel LogLevel `json:"file_info_level"` // 输出类型 Encoder encoder `json:"encoder"` // 记录上次切割文件的时间 LastSplitTime time.Time // 日志文件对象 FileObj *os.File // Error日志文件对象 ErrFileObj *os.File // 异步写日志 管道 LogChan chan *LogMsg CheckTime time.Duration }
func NewFileLogger ¶
func NewFileLogger(level LogLevel, fp, fn string, options ...LogoHandleFunc) *FileLogger
FileLogger 构造函数
func (*FileLogger) CheckFileCount ¶
func (fl *FileLogger) CheckFileCount()
func (*FileLogger) CheckFileMaxAge ¶
func (fl *FileLogger) CheckFileMaxAge()
func (*FileLogger) CheckFileSize ¶
func (fl *FileLogger) CheckFileSize(file *os.File) bool
func (*FileLogger) CheckSplitFileAge ¶
func (fl *FileLogger) CheckSplitFileAge(now time.Time) bool
func (*FileLogger) Debug ¶
func (fl *FileLogger) Debug(msg string)
func (*FileLogger) Debugf ¶
func (fl *FileLogger) Debugf(format string, args ...interface{})
func (*FileLogger) Error ¶
func (fl *FileLogger) Error(msg string)
func (*FileLogger) Errorf ¶
func (fl *FileLogger) Errorf(format string, args ...interface{})
func (*FileLogger) Fatal ¶
func (fl *FileLogger) Fatal(msg string)
func (*FileLogger) Fatalf ¶
func (fl *FileLogger) Fatalf(format string, args ...interface{})
func (*FileLogger) Info ¶
func (fl *FileLogger) Info(msg string)
func (*FileLogger) Infof ¶
func (fl *FileLogger) Infof(format string, args ...interface{})
func (*FileLogger) JsonEncode ¶
func (fl *FileLogger) JsonEncode(logMsg *LogMsg) []byte
func (*FileLogger) Log ¶
func (fl *FileLogger) Log(level LogLevel, format string, args ...interface{})
func (*FileLogger) RemoveMoreMaxAgeFile ¶
func (fl *FileLogger) RemoveMoreMaxAgeFile(loc *time.Location)
func (*FileLogger) RemoveMoreMaxCountFile ¶
func (fl *FileLogger) RemoveMoreMaxCountFile(loc *time.Location)
func (*FileLogger) SetEncoder ¶
func (fl *FileLogger) SetEncoder(encode encoder)
func (*FileLogger) SetFileInfo ¶
func (fl *FileLogger) SetFileInfo(level LogLevel)
func (*FileLogger) SetPrefix ¶
func (fl *FileLogger) SetPrefix(prefix string)
func (*FileLogger) SetTimeFormat ¶
func (fl *FileLogger) SetTimeFormat(format string)
func (*FileLogger) TextEncode ¶
func (fl *FileLogger) TextEncode(logMsg *LogMsg) []byte
func (*FileLogger) Trace ¶
func (fl *FileLogger) Trace(msg string)
func (*FileLogger) Tracef ¶
func (fl *FileLogger) Tracef(format string, args ...interface{})
func (*FileLogger) Warning ¶
func (fl *FileLogger) Warning(msg string)
func (*FileLogger) Warningf ¶
func (fl *FileLogger) Warningf(format string, args ...interface{})
type Logger ¶
type Logger interface { Debug(msg string) Trace(msg string) Info(msg string) Warning(msg string) Error(msg string) Fatal(msg string) Debugf(format string, args ...interface{}) Tracef(format string, args ...interface{}) Infof(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) SetPrefix(prefix string) SetTimeFormat(format string) SetFileInfo(level LogLevel) SetEncoder(encode encoder) }
type LogoHandleFunc ¶
type LogoHandleFunc interface {
Configure(*FileLogger) error
}
func WithCheckTime ¶
func WithCheckTime(t time.Duration) LogoHandleFunc
func WithEncoder ¶
func WithEncoder(encode encoder) LogoHandleFunc
func WithMaxAge ¶
func WithMaxAge(maxAge int) LogoHandleFunc
func WithMaxCount ¶
func WithMaxCount(count int, errCount int) LogoHandleFunc
func WithMaxFileSize ¶
func WithMaxFileSize(size int64) LogoHandleFunc
func WithSplitAge ¶
func WithSplitAge(splitFileAge int) LogoHandleFunc
type MaxFileCount ¶
type OptionFn ¶
type OptionFn func(*FileLogger) error
func (OptionFn) Configure ¶
func (o OptionFn) Configure(fl *FileLogger) error
Click to show internal directories.
Click to hide internal directories.