func (cl *ChannelLogger) FlushLogLines() [][]interface{} {
	logLines := make([][]interface{}, 0, cl.ch.Len())
	cl.Flush(log.LoggerFunc(func(keyvals ...interface{}) error {
		logLines = append(logLines, keyvals)
		return nil
	}))
	return logLines
}
Drains the next contiguous segment of loglines up to the buffer cap waiting
for at least one line
package loggers
import (
	"sync"
	"github.com/eapache/channels"
	"github.com/go-kit/kit/log"
)
const (
	DefaultLoggingRingBufferCap channels.BufferCap = 100
)
type ChannelLogger struct {
	ch channels.Channel
	sync.RWMutex
}
var _ log.Logger = (*ChannelLogger)(nil)
func NewChannelLogger(loggingRingBufferCap channels.BufferCap) *ChannelLogger {
	return &ChannelLogger{
		ch: channels.NewRingChannel(loggingRingBufferCap),
	}
}
func (cl *ChannelLogger) Log(keyvals ...interface{}) error {
	cl.RWMutex.RLock()
	cl.ch.In() <- keyvals
	cl.RWMutex.RUnlock()
	return nil
}
func (cl *ChannelLogger) BufferLength() int {
	return cl.ch.Len()
}
func (cl *ChannelLogger) BufferCap() channels.BufferCap {
	return cl.ch.Cap()
}
func (cl *ChannelLogger) WaitReadLogLine() []interface{} {
	logLine, ok := <-cl.ch.Out()
	return readLogLine(logLine, ok)
}
func (cl *ChannelLogger) ReadLogLine() []interface{} {
	select {
	case logLine, ok := <-cl.ch.Out():
		return readLogLine(logLine, ok)
	default:
		return nil
	}
}
func readLogLine(logLine interface{}, ok bool) []interface{} {
	if !ok {
		return nil
	}
	return logLine.([]interface{})
}
func (cl *ChannelLogger) DrainForever(logger log.Logger) {
	for logLine := cl.WaitReadLogLine(); logLine != nil; logLine = cl.WaitReadLogLine() {
		logger.Log(logLine...)
	}
}
func (cl *ChannelLogger) Flush(logger log.Logger) {
	bufferLength := cl.BufferLength()
	for i := 0; i < bufferLength; i++ {
		logLine := cl.WaitReadLogLine()
		if logLine != nil {
			logger.Log(logLine...)
		}
	}
}