Documentation ¶
Overview ¶
Package logs 日志系统
Index ¶
- Constants
- func Caller(l *Logs)
- func Created(l *Logs)
- type Entry
- type Level
- type Logger
- type Logs
- func (logs *Logs) DEBUG() Logger
- func (logs *Logs) Debug(v ...interface{})
- func (logs *Logs) Debugf(format string, v ...interface{})
- func (logs *Logs) ERROR() Logger
- func (logs *Logs) Enable(level ...Level)
- func (logs *Logs) Error(v ...interface{})
- func (logs *Logs) Errorf(format string, v ...interface{})
- func (logs *Logs) FATAL() Logger
- func (logs *Logs) Fatal(v ...interface{})
- func (logs *Logs) Fatalf(format string, v ...interface{})
- func (logs *Logs) HasCaller() bool
- func (logs *Logs) HasCreated() bool
- func (logs *Logs) INFO() Logger
- func (logs *Logs) Info(v ...interface{})
- func (logs *Logs) Infof(format string, v ...interface{})
- func (logs *Logs) IsEnable(l Level) bool
- func (logs *Logs) Logger(lv Level) Logger
- func (logs *Logs) NewEntry(lv Level) *Entry
- func (logs *Logs) Output(e *Entry)
- func (logs *Logs) SetOutput(w Writer)
- func (logs *Logs) StdLogger(l Level) *log.Logger
- func (logs *Logs) TRACE() Logger
- func (logs *Logs) Trace(v ...interface{})
- func (logs *Logs) Tracef(format string, v ...interface{})
- func (logs *Logs) WARN() Logger
- func (logs *Logs) Warn(v ...interface{})
- func (logs *Logs) Warnf(format string, v ...interface{})
- type Option
- type Pair
- type Writer
- func MergeWriter(w ...Writer) Writer
- func NewDispatchWriter(d map[Level]Writer) Writer
- func NewJSONWriter(format bool, w ...io.Writer) Writer
- func NewNopWriter() Writer
- func NewTermWriter(timeLayout string, fore colors.Color, w io.Writer) Writer
- func NewTextWriter(timeLayout string, w ...io.Writer) Writer
Constants ¶
View Source
const ( MilliLayout = "15:04:05.000" MicroLayout = "15:04:05.000000" NanoLayout = "15:04:05.000000000" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct { Level Level `json:"level"` Created time.Time `json:"created,omitempty"` // 日志的生成时间 Message string `json:"message"` // 以下表示日志的定位信息 Path string `json:"path,omitempty"` Line int `json:"line,omitempty"` // 额外的数据保存在此,比如由 Logger.Value 添加的数据。 Params []Pair `json:"params,omitempty"` // contains filtered or unexported fields }
Entry 每一条日志产生的数据
type Level ¶
type Level int8
const ( LevelInfo Level LevelTrace LevelDebug LevelWarn LevelError LevelFatal )
目前支持的日志类型
func ParseLevel ¶
func (Level) MarshalText ¶
func (*Level) UnmarshalText ¶
type Logs ¶
type Logs struct {
// contains filtered or unexported fields
}
type Writer ¶
type Writer interface { // WriteEntry 将 Entry 写入日志通道 // // NOTE: 此方法应该保证以换行符结尾。 WriteEntry(*Entry) }
Writer 将 Entry 转换成文本并输出的功能
func NewDispatchWriter ¶
NewDispatchWriter 根据 Level 派发到不同的 Writer 对象
func NewTermWriter ¶
NewTermWriter 带颜色的终端输出通道
timeLayout 表示输出的时间格式,遵守 time.Format 的参数要求,如果为空,则不输出时间信息; fore 表示终端信息的字符颜色,背景始终是默认色; w 表示终端的接口,可以是 os.Stderr 或是 os.Stdout,如果是其它的实现者则会带控制字符一起输出;
Click to show internal directories.
Click to hide internal directories.