Documentation ¶
Index ¶
- Constants
- func Compose(handlers ...func(log.Logger) log.Logger) func(log.Logger) log.Logger
- func NewFilterLogger(outputLogger log.Logger, predicate func(keyvals []interface{}) bool) log.Logger
- func NewMultipleOutputLogger(outputLoggers ...log.Logger) log.Logger
- func NonBlockingLogger(outputLogger log.Logger) log.Logger
- func VectorValuedLogger(logger log.Logger) log.Logger
- type ChannelLogger
- func (cl *ChannelLogger) BufferCap() channels.BufferCap
- func (cl *ChannelLogger) BufferLength() int
- func (cl *ChannelLogger) DrainForever(logger log.Logger)
- func (cl *ChannelLogger) Flush(logger log.Logger)
- func (cl *ChannelLogger) FlushLogLines() [][]interface{}
- func (cl *ChannelLogger) Log(keyvals ...interface{}) error
- func (cl *ChannelLogger) ReadLogLine() []interface{}
- func (cl *ChannelLogger) Reset()
- func (cl *ChannelLogger) WaitReadLogLine() []interface{}
- type MultipleOutputLogger
Constants ¶
const (
DefaultLoggingRingBufferCap channels.BufferCap = 100
)
Variables ¶
This section is empty.
Functions ¶
func Compose ¶
Apply a pipeline of log handlers, the handlers will are applied with the from right to left so the earlier handlers are the outermost ones, so for an incoming message 'msg' and handlers 'h1', 'h2', 'h3': msg -> Compose(h1,h2,h3)(baseLogger) = msg -> h1 -> h2 -> h3 -> baseLogger
func NewFilterLogger ¶
func NewFilterLogger(outputLogger log.Logger, predicate func(keyvals []interface{}) bool) log.Logger
Creates a logger that removes lines from output when the predicate evaluates true
func NewMultipleOutputLogger ¶
Creates a logger that forks log messages to each of its outputLoggers
func NonBlockingLogger ¶
Returns a Logger that wraps the outputLogger passed and does not block on calls to Log.
Types ¶
type ChannelLogger ¶
func NewChannelLogger ¶
func NewChannelLogger(loggingRingBufferCap channels.BufferCap) *ChannelLogger
Creates a Logger that uses a uses a non-blocking ring buffered channel. This logger provides a common abstraction for both a buffered, flushable logging cache. And a non-blocking conduit to transmit logs via DrainForever (or NonBlockingLogger).
func (*ChannelLogger) BufferCap ¶
func (cl *ChannelLogger) BufferCap() channels.BufferCap
Get the cap off the internal ring buffer
func (*ChannelLogger) BufferLength ¶
func (cl *ChannelLogger) BufferLength() int
Get the current occupancy level of the ring buffer
func (*ChannelLogger) DrainForever ¶
func (cl *ChannelLogger) DrainForever(logger log.Logger)
Enters an infinite loop that will drain any log lines from the passed logger.
Exits if the channel is closed.
func (*ChannelLogger) Flush ¶
func (cl *ChannelLogger) Flush(logger log.Logger)
Drains everything that is available at the time of calling
func (*ChannelLogger) FlushLogLines ¶
func (cl *ChannelLogger) FlushLogLines() [][]interface{}
Drains the next contiguous segment of loglines up to the buffer cap waiting for at least one line
func (*ChannelLogger) Log ¶
func (cl *ChannelLogger) Log(keyvals ...interface{}) error
func (*ChannelLogger) ReadLogLine ¶
func (cl *ChannelLogger) ReadLogLine() []interface{}
Tries to read a log line from the channel buffer or returns nil if none is immediately available
func (*ChannelLogger) Reset ¶
func (cl *ChannelLogger) Reset()
Close the existing channel halting goroutines that are draining the channel and create a new channel to buffer into. Should not cause any log lines arriving concurrently to be lost, but any that have not been drained from old channel may be.
func (*ChannelLogger) WaitReadLogLine ¶
func (cl *ChannelLogger) WaitReadLogLine() []interface{}
Read a log line by waiting until one is available and returning it
type MultipleOutputLogger ¶
This represents an 'AND' type logger. When logged to it will log to each of the loggers in the slice.
func (MultipleOutputLogger) Log ¶
func (mol MultipleOutputLogger) Log(keyvals ...interface{}) error