orbiter/utils/hook/channel.go
Gianluca Arbezzano 1709cf5150 Event stream
2017-02-24 00:16:28 +00:00

27 lines
381 B
Go

package hook
import "github.com/Sirupsen/logrus"
type Channel struct {
c chan *logrus.Entry
}
func NewChannelHook(cc chan *logrus.Entry) Channel {
return Channel{
c: cc,
}
}
func (channel Channel) Levels() []logrus.Level {
return logrus.AllLevels
}
func (channel Channel) Fire(entry *logrus.Entry) error {
select {
case channel.c <- entry:
default:
}
return nil
}