Documentation
¶
Index ¶
- 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 GetContext() string
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func RegisterHook(f func(*Log))
- func SetContext(name string)
- func SetDriver(d Driver)
- func SetLevel(l Level)
- func Trace(v ...interface{})
- func Tracef(format string, v ...interface{})
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- type Driver
- type Fields
- type Level
- type Log
- type Logger
- func (l *Logger) BindFields(fields Fields)
- 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) IsDebugEnabled() bool
- func (l *Logger) IsErrorEnabled() bool
- func (l *Logger) IsFatalEnabled() bool
- func (l *Logger) IsInfoEnabled() bool
- func (l *Logger) IsPanicEnabled() bool
- func (l *Logger) IsTraceEnabled() bool
- func (l *Logger) IsWarnEnabled() bool
- func (l *Logger) Level() Level
- func (l *Logger) Name() string
- func (l *Logger) Panic(v ...interface{})
- func (l *Logger) Panicf(format string, v ...interface{})
- func (l *Logger) Trace(v ...interface{})
- func (l *Logger) Tracef(format string, v ...interface{})
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- func (l *Logger) WithFields(fields Fields) *Logger
- type Stack
- type StdDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf record debug level's log with custom format.
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf record error level's log with custom format.
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf record fatal level's log with custom format.
func Infof ¶
func Infof(format string, v ...interface{})
Infof record info level's log with custom format.
func Panicf ¶
func Panicf(format string, v ...interface{})
Panic record panic level's log with custom format
func RegisterHook ¶
func RegisterHook(f func(*Log))
RegisterHook register a hook, all log will inform it
func SetLevel ¶
func SetLevel(l Level)
SetLevel update the global level, all lower level will not be send to driver to print
Types ¶
type Driver ¶
type Driver interface {
// Retrieve the name of current driver, like 'default', 'logrus'...
Name() string
// Print responsible of printing the standard Log
Print(l *Log)
// Retrieve log level of the specified logger,
// it should return the lowest Level that could be print,
// which can help invoker to decide whether prepare print or not.
GetLevel(logger string) Level
}
Driver define the standard log print specification
type Log ¶
type Log struct {
Time int64 `json:"date"` // log's time(us)
Logger string `json:"logger"` // log's name, default is package
Pid int `json:"pid"` // the process id which generated this log
Gid int `json:"gid"` // the goroutine id which generated this log
Stack *Stack `json:"stack"` // the stack info of this log
DebugStack *string `json:"debug_stack"` // the debug stack of this log
Level Level `json:"level"` // log's level
Format *string `json:"format"` // log's format
Args []interface{} `json:"args"` // log's format args
Fields Fields `json:"fields"` // additional custom fields
}
Log represent an log, contains all properties.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger wrap independent logger
func (*Logger) BindFields ¶
BindFields add the specified fields into the current Logger.
func (*Logger) IsDebugEnabled ¶
Whether debug of current logger enabled or not
func (*Logger) IsErrorEnabled ¶
Whether error of current logger enabled or not
func (*Logger) IsFatalEnabled ¶
Whether fatal of current logger enabled or not
func (*Logger) IsInfoEnabled ¶
Whether info of current logger enabled or not
func (*Logger) IsPanicEnabled ¶
Whether panic of current logger enabled or not
func (*Logger) IsTraceEnabled ¶
Whether trace of current logger enabled or not
func (*Logger) IsWarnEnabled ¶
Whether warn of current logger enabled or not
func (*Logger) WithFields ¶
WithFields derive an new Logger by the specified fields from the current Logger.
type Stack ¶
type Stack struct {
Package string `json:"package"`
Filename string `json:"filename"`
Function string `json:"function"`
Line int `json:"line"`
// contains filtered or unexported fields
}
Stack represent pc's stack details.
func ParseStack ¶
ParseStack retrieve pc's stack details, should cache result for performance optimization.