strip logger

This commit is contained in:
Asim Aslam
2019-12-17 18:34:21 +00:00
parent 5a52593e66
commit e9efcbe8dc
5 changed files with 18 additions and 167 deletions

View File

@@ -18,7 +18,10 @@ func (k *klog) Write(l log.Record) error {
}
func (k *klog) Stream() (log.Stream, error) {
return &klogStreamer{}, nil
return &klogStreamer{
streamChan: make(chan log.Record),
stop: make(chan bool),
}, nil
}
// New returns a configured Kubernetes logger

View File

@@ -18,17 +18,23 @@ func write(l log.Record) error {
}
type klogStreamer struct {
// the k8s log stream
streamChan chan log.Record
// the stop chan
stop chan bool
}
func (k *klogStreamer) Chan() <-chan log.Record {
if k.streamChan == nil {
k.streamChan = make(chan log.Record)
}
return k.streamChan
}
func (k *klogStreamer) Stop() error {
close(k.streamChan)
select {
case <-k.stop:
return nil
default:
close(k.stop)
close(k.streamChan)
}
return nil
}