Documentation
¶
Overview ¶
log package enables simple levelled logging This is a thin wrapper around log15 which provides most of the functionality. We are wrapping primarily to not have to use "log15" as an import (which is just weird).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BadConf error = errors.New("Bad configuration")
var Crit = log15.Crit
var Debug = log15.Debug
var Error = log15.Error
var Info = log15.Info
var New = log15.New
var Root = log15.Root
var Warn = log15.Warn
Functions ¶
func SetHandler ¶
func SetHandler(hdlr Handler)
Types ¶
type Format ¶
type Format log15.Format
func MakeFormatter ¶
func MakeFormatter(format FormatConf) (Format, error)
MakeFormatter constructs a object of type Format based on the specified format conf and returns it Currently @format has to be a string with one of json | json_pretty | logfmt | terminal
type FormatConf ¶
type FormatConf interface{}
type Handler ¶
type Handler log15.Handler
func MakeBasicHandler ¶
MakeBasicHandler prepares a log handler that writes to both a file at @fpath and stderr both with log level @lvl if @fpath is "", then it assumes it shouldn't write to a file and if @quiet is true, then it doesn't print to stderr
func MakeHandler ¶
func MakeHandler(conf HandlerConf) (Handler, error)
MakeHandler accepts a handler configuration and constructs a usable
handler. The handler config can be used to create sophistacted behavior by composing handlers as described here "https://godoc.org/gopkg.in/inconshreveable/log15.v2#Handler" A HandlerConf is a sequence of values of the following format [handlerType string, args ...interface{}] eg: HandlerConf{"file", "/tmp/test.log", "json"} In the above example, we have defined a file handler where the logs are to be written to the file "/tmp/test.log" in "json" format. Here is an example of a slightly more complex handler eg: HandlerConf{"level_filter", "debug", HandlerConf{"file", "/tmp/test.log", "json"}, } In the above example, we defined a file handler just like above but in wrapping it with a "level_filter" handler, we've specified that only log statements that are greater than or equal to the specified level "debug". NOTE: for additional information about the following please refer to the godoc link placed above. List of handler formats: json json_pretty logfmt terminal List of handlers: - buffered (bufSize int, handler HandlerConf) - caller_file (handler HandlerConf) - caller_func (handler HandlerConf) - caller_stack (format string, handler HandlerConf) - discard () - failover (handler ...HandlerConf) - file (path string, format string) - lazy (handler HandlerConf) - level_filter (level string, handler HandlerConf) level = debug | info | warn | error | crit - match_filter (key string, value string|int|float, handler HandlerConf) - multi (handler ...HandlerConf) - net (network string, address string, format string) - stream (stream string, format string) stream = stdout | stderr - sync (handler HandlerConf) - syslog (tag string, format string) - syslog_net (net string, address string, tag string, format string) - redis (ip_port string, channel string) `ip_port` is of the format "ip:port". port part is optional. on omission the default redis port 6379 is assumed. `channel` is the name of the redis channel to which the log statements are to be written.
func MakeNoopHandler ¶
MakeNoopHandler prepares a log handler that discards all the log statements that are sent to it
type HandlerConf ¶
type HandlerConf []interface{}
type LogToLog15 ¶
type LogToLog15 struct { }
type RecordKeyNames ¶
type RecordKeyNames log15.RecordKeyNames
type RedisHandler ¶
func (*RedisHandler) Init ¶
func (p *RedisHandler) Init() error
func (RedisHandler) Log ¶
func (p RedisHandler) Log(r *log15.Record) error