Documentation ¶
Index ¶
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func DelContextField(key string)
- func EnableAsyncDriver()
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func GetContext() string
- func GetContextField(key string) (value interface{})
- 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 SetContextField(key string, value interface{})
- func SetContextFields(fields Fields)
- func SetDriver(d Driver)
- func SetLevel(lv Level)
- func SetLoggerLevel(loggerName string, level Level)
- func SetLoggerLevelMap(levelMap map[string]Level)
- func Trace(v ...interface{})
- func Tracef(format string, v ...interface{})
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- type AsyncDriver
- type Driver
- type Fields
- type Level
- type LevelSetting
- type Log
- type Logger
- type Stack
- type StdDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelContextField ¶ added in v1.1.0
func DelContextField(key string)
func EnableAsyncDriver ¶ added in v1.0.10
func EnableAsyncDriver()
EnableAsyncDriver enable the AsyncDriver, it has better performance
func GetContextField ¶ added in v1.1.0
func GetContextField(key string) (value interface{})
func RegisterHook ¶
func RegisterHook(f func(*Log))
RegisterHook register a hook, all log will inform it
func SetContextField ¶ added in v1.1.0
func SetContextField(key string, value interface{})
func SetContextFields ¶ added in v1.1.0
func SetContextFields(fields Fields)
func SetLevel ¶
func SetLevel(lv Level)
SetLevel update the global level, all lower level will not be send to driver to print
func SetLoggerLevel ¶ added in v1.0.8
SetLoggerLevel setup log-level of the specified logger by name
func SetLoggerLevelMap ¶ added in v1.0.8
SetLoggerLevelMap batch set logger's level
Types ¶
type AsyncDriver ¶ added in v1.0.10
type AsyncDriver struct {
// contains filtered or unexported fields
}
AsyncDriver The async driver, it should have better performance
func (*AsyncDriver) GetLevel ¶ added in v1.0.10
func (t *AsyncDriver) GetLevel(_ string) Level
func (*AsyncDriver) Name ¶ added in v1.0.10
func (t *AsyncDriver) Name() string
func (*AsyncDriver) Print ¶ added in v1.0.10
func (t *AsyncDriver) Print(l *Log)
type Driver ¶
type Driver interface { // Name return the name of current driver, like 'default', 'logrus'... Name() string // Print responsible of printing the standard Log Print(l *Log) // GetLevel return 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 LevelSetting ¶ added in v1.0.8
type LevelSetting struct {
// contains filtered or unexported fields
}
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 CxtFields Fields `json:"cxt_fields"` // caller's goroutine context fields }
Log represent an log, contains all properties.
type Logger ¶
type Logger interface { // Name obtain logger's name Name() string // Level obtain logger's level, lower will not be print Level() Level // BindFields add the specified fields into the current Logger. BindFields(fields Fields) // WithFields derive an new Logger by the specified fields from the current Logger. WithFields(fields Fields) Logger // IsTraceEnabled Whether trace of current logger enabled or not IsTraceEnabled() bool // IsDebugEnabled Whether debug of current logger enabled or not IsDebugEnabled() bool // IsInfoEnabled Whether info of current logger enabled or not IsInfoEnabled() bool // IsWarnEnabled Whether warn of current logger enabled or not IsWarnEnabled() bool // IsErrorEnabled Whether error of current logger enabled or not IsErrorEnabled() bool // IsPanicEnabled Whether panic of current logger enabled or not IsPanicEnabled() bool // IsFatalEnabled Whether fatal of current logger enabled or not IsFatalEnabled() bool // Trace record trace level's log Trace(v ...interface{}) // Tracef record trace level's log with custom format. Tracef(format string, v ...interface{}) // Debug record debug level's log Debug(v ...interface{}) // Debugf record debug level's log with custom format. Debugf(format string, v ...interface{}) // Info record info level's log Info(v ...interface{}) // Infof record info level's log with custom format. Infof(format string, v ...interface{}) // Warn record warn level's log Warn(v ...interface{}) // Warnf record warn level's log with custom format. Warnf(format string, v ...interface{}) // Error record error level's log Error(v ...interface{}) // Errorf record error level's log with custom format. Errorf(format string, v ...interface{}) // Panic record panic level's log Panic(v ...interface{}) // Panicf record panic level's log with custom format Panicf(format string, v ...interface{}) // Fatal record fatal level's log Fatal(v ...interface{}) // Fatalf record fatal level's log with custom format. Fatalf(format string, v ...interface{}) }
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.
func ParseStack2 ¶ added in v1.0.8
ParseStack2 this is slower, cannot use it.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.