micro/debug/log/kubernetes/stream.go
Vasiliy Tolstov f23638c036 fix import paths for v2 release
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-01-30 14:44:40 +03:00

41 lines
570 B
Go

package kubernetes
import (
"encoding/json"
"fmt"
"os"
"github.com/micro/go-micro/v2/debug/log"
)
func write(l log.Record) error {
m, err := json.Marshal(l)
if err == nil {
_, err := fmt.Fprintf(os.Stderr, "%s", m)
return err
}
return err
}
type kubeStream struct {
// the k8s log stream
stream chan log.Record
// the stop chan
stop chan bool
}
func (k *kubeStream) Chan() <-chan log.Record {
return k.stream
}
func (k *kubeStream) Stop() error {
select {
case <-k.stop:
return nil
default:
close(k.stop)
close(k.stream)
}
return nil
}