Documentation
¶
Overview ¶
Package logging is the wrapper of log15(https://github.com/inconshreveable/log15), but it also supports Debugf, Infof, Warnf, Errorf and Critf.
The package initialized a default global `Logger` and you maybe and should use it. For example,
// Initialize the logger. // Notice: this is optional. The log is output to os.Stderr by default. handler := NewHandler(...) logging.SetHandler(handler) // Write the log logging.Debugf("debug: %d", 1) logging.Infof("info: %s", "test")
Index ¶
- Variables
- func Crit(msg string, ctx ...interface{})
- func Critf(format string, args ...interface{})
- func Debug(msg string, ctx ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(msg string, ctx ...interface{})
- func Errorf(format string, args ...interface{})
- func Info(msg string, ctx ...interface{})
- func Infof(format string, args ...interface{})
- func SetDefaultLogger(l Logger)
- func SetHandler(h Handler)
- func Warn(msg string, ctx ...interface{})
- func Warnf(format string, args ...interface{})
- type Format
- type Handler
- type Lazy
- type Logger
- func (l Logger) Critf(format string, args ...interface{})
- func (l Logger) Debugf(format string, args ...interface{})
- func (l Logger) Errorf(format string, args ...interface{})
- func (l Logger) Infof(format string, args ...interface{})
- func (l Logger) New(cxt ...interface{}) Logger
- func (l Logger) Warnf(format string, args ...interface{})
- type Lvl
- type Record
- type RecordKeyNames
Constants ¶
This section is empty.
Variables ¶
var ( // TerminalFormat is a terminal formatter. // It's the alias of log15.TerminalFormat. TerminalFormat = log15.TerminalFormat // LogfmtFormat is a logfmt formatter. // It's the alias of log15.LogfmtFormat. LogfmtFormat = log15.LogfmtFormat // JsonFormat is a JSON formatter to format the record into JSON. // It's the alias of log15.JsonFormat. JsonFormat = log15.JsonFormat // JsonFormatEx is a JSON formatter, which can output the pretty log. // It's the alias of log15.JsonFormatEx. JsonFormatEx = log15.JsonFormatEx )
some predefined formatters.
var ( // BufferedHandler is a buffer handler. // // It's the alias of log15.BufferedHandler. BufferedHandler = log15.BufferedHandler // CallerFileHandler will add the line number of the file name of the // calling function with the key "caller" to the context. // // It's the alias of log15.CallerFileHandler CallerFileHandler = log15.CallerFileHandler // CallerFuncHandler will add the calling function name with the key "key" // to the context. // // It's the alias of log15.CallerFuncHandler. CallerFuncHandler = log15.CallerFuncHandler // CallerStackHandler will add the stack trace with the key "stack" to the // context. // // It's the alias of log15.CallerStackHandler. CallerStackHandler = log15.CallerStackHandler // ChannelHandler will write all log records to the given channel, // which blocks if the channel is full. // // It's the alias of log15.ChannelHandler. ChannelHandler = log15.ChannelHandler // DiscardHandler will discard all log records then report success. // // It's the alias of log15.DiscardHandler. DiscardHandler = log15.DiscardHandler // FailoverHandler will write all log records to the first handler, but will // failover and write to the second handler if the first handler has failed. // And so on for all handlers. // // It's the alias of log15.FailoverHandler. FailoverHandler = log15.FailoverHandler // FileHandler is a file handler. // // It's the alias of log15.FileHandler. FileHandler = log15.FileHandler // FilterHandler is a handler with the filter. // // It's the alias of log15.FilterHandler. FilterHandler = log15.FilterHandler // FuncHandler will write all log records to the given function. // // It's the alias of log15.FuncHandler. FuncHandler = log15.FuncHandler // LazyHandler is a lazy handler. // // It's the alias of log15.LazyHandler. LazyHandler = log15.LazyHandler // LvlFilterHandler is a handler with a level filter. // // It's the alias of log15.LvlFilterHandler. LvlFilterHandler = log15.LvlFilterHandler // MatchFilterHandler only writes the log records matching the key-value. // // It's the alias of log15.MatchFilterHandler. MatchFilterHandler = log15.MatchFilterHandler // MultiHandler will dispatch the log record to each of the given handlers. // // It's the alias of log15.MultiHandler. MultiHandler = log15.MultiHandler // NetHandler will send out the log records by the network. // // It's the alias of log.NetHandler. NetHandler = log15.NetHandler // StreamHandler will write all log records to the io.Writer. // // It's the alias of log15.StreamHandler. StreamHandler = log15.StreamHandler // SyncHandler will guarantee that only a single log operation can proceed // at a time. // // It's the alias of log15.SyncHandler. SyncHandler = log15.SyncHandler )
Some handlers
var ( // LvlCrit is the critical level. LvlCrit = log15.LvlCrit // LvlError is the error level. LvlError = log15.LvlError // LvlWarn is the warning level. LvlWarn = log15.LvlWarn // LvlInfo is the info level. LvlInfo = log15.LvlInfo // LvlDebug is the debug level. LvlDebug = log15.LvlDebug )
The predefined levels.
var FormatFunc = log15.FormatFunc
FormatFunc converts a function to Format.
var LvlFromString = log15.LvlFromString
LvlFromString convert the level name to Lvl.
Functions ¶
func Crit ¶
func Crit(msg string, ctx ...interface{})
Crit is equal to GetDefaultLogger().Crit(msg, ctx...).
func Critf ¶
func Critf(format string, args ...interface{})
Critf is equal to GetDefaultLogger().Critf(format, args...).
func Debug ¶
func Debug(msg string, ctx ...interface{})
Debug is equal to GetDefaultLogger().Debug(msg, ctx...).
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf is equal to GetDefaultLogger().Debugf(format, args...).
func Error ¶
func Error(msg string, ctx ...interface{})
Error is equal to GetDefaultLogger().Error(msg, ctx...).
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf is equal to GetDefaultLogger().Errorf(format, args...).
func Info ¶
func Info(msg string, ctx ...interface{})
Info is equal to GetDefaultLogger().Info(msg, ctx...).
func Infof ¶
func Infof(format string, args ...interface{})
Infof is equal to GetDefaultLogger().Infof(format, args...).
func SetDefaultLogger ¶
func SetDefaultLogger(l Logger)
SetDefaultLogger resets the default global logger.
func SetHandler ¶
func SetHandler(h Handler)
SetHandler updates the default global logger to write records to the specified handler.
Types ¶
type Handler ¶
Handler is the alias of log15.Handler.
func GetHandler ¶
func GetHandler() Handler
GetHandler gets the handler associated with the default global logger.
type Logger ¶
Logger is a logger based on log15.
func GetDefaultLogger ¶
func GetDefaultLogger() Logger
GetDefaultLogger returns the default global logger.
type RecordKeyNames ¶
type RecordKeyNames = log15.RecordKeyNames
RecordKeyNames are the predefined names of the log properties.