README
¶
日志级别
- Fatal 致命的
- Panic 严重的
- Error 错误的
- Warn 告警的
- Info 信息的
- Debug 调试的
文件说明
log.go
对外开放的方法,默认console适配器,属于第1层级logger.go
log对象,像SetAdapter
WithHook
是项目及全局方法,属于第2层级entry.go
实体类,每次产生一条log时,都要new
实体类,主要处理消息内容、标签、附加数据等,属于第3层级message.go
消息内容对象,包装每条消息包含的字段信息adapter.go
适配器console.go
控制台适配器file.go
文件适配器file_options.go
文件适配器 选项
文件适配器
filepath
日志保存目录filename
日志文件名,使用yyyymmdd.log
maxSize
文件大小最大值,默认512M,超过后,会切割文件FilePathOption()
定义文件路径FileMaxSizeOption()
定义文件大小最大值
输出对象
- console
- file
- kafka
- es
Documentation
¶
Index ¶
- Variables
- func Debug(v ...interface{})
- func DebugF(format string, v ...interface{})
- func Error(v ...interface{})
- func ErrorF(format string, v ...interface{})
- func Fatal(v ...interface{})
- func FatalF(format string, v ...interface{})
- func Info(v ...interface{})
- func InfoF(format string, v ...interface{})
- func Panic(v ...interface{})
- func PanicF(format string, v ...interface{})
- func SetAdapter(adapter Adapter)
- func Warn(v ...interface{})
- func WarnF(format string, v ...interface{})
- func WithHook(fns ...func(msg *Message))
- type Adapter
- type ConsoleAdapter
- type DataField
- type Entry
- func (entry *Entry) Debug(v ...interface{})
- func (entry *Entry) DebugF(format string, v ...interface{})
- func (entry *Entry) Error(v ...interface{})
- func (entry *Entry) ErrorF(format string, v ...interface{})
- func (entry *Entry) Fatal(v ...interface{})
- func (entry *Entry) FatalF(format string, v ...interface{})
- func (entry *Entry) Info(v ...interface{})
- func (entry *Entry) InfoF(format string, v ...interface{})
- func (entry *Entry) Panic(v ...interface{})
- func (entry *Entry) PanicF(format string, v ...interface{})
- func (entry *Entry) Warn(v ...interface{})
- func (entry *Entry) WarnF(format string, v ...interface{})
- func (entry *Entry) WithField(field string, value interface{}) *Entry
- func (entry *Entry) WithTag(tags ...string) *Entry
- func (entry *Entry) WithTrace() *Entry
- type FileAdapter
- type FileOption
- type Level
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) DebugF(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) ErrorF(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) FatalF(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) InfoF(format string, v ...interface{})
- func (l *Logger) Panic(v ...interface{})
- func (l *Logger) PanicF(format string, v ...interface{})
- func (l *Logger) SetAdapter(adapter Adapter)
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) WarnF(format string, v ...interface{})
- func (l *Logger) WithField(field string, value interface{}) *Entry
- func (l *Logger) WithHook(fns ...func(msg *Message))
- func (l *Logger) WithTag(tags ...string) *Entry
- func (l *Logger) WithTrace() *Entry
- type Message
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func SetAdapter ¶
func SetAdapter(adapter Adapter)
Types ¶
type ConsoleAdapter ¶
type ConsoleAdapter struct { }
func (*ConsoleAdapter) Write ¶
func (ca *ConsoleAdapter) Write(msg *Message)
type Entry ¶
type FileAdapter ¶
type FileAdapter struct {
// contains filtered or unexported fields
}
func NewFileAdapter ¶
func NewFileAdapter(opt ...FileOption) *FileAdapter
func (*FileAdapter) Write ¶
func (fa *FileAdapter) Write(msg *Message)
type FileOption ¶ added in v1.1.1
type FileOption interface {
// contains filtered or unexported methods
}
func FileMaxSizeOption ¶
func FileMaxSizeOption(maxSize int64) FileOption
func FilePathOption ¶ added in v1.1.1
func FilePathOption(filepath string) FileOption
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewConsoleLog ¶ added in v1.1.1
func NewConsoleLog() *Logger
func NewFileLog ¶ added in v1.1.1
func NewFileLog(opts ...FileOption) *Logger
func (*Logger) SetAdapter ¶
Click to show internal directories.
Click to hide internal directories.