mirror of
https://github.com/spaytac/orbiter.git
synced 2026-01-21 23:14:43 +00:00
27 lines
381 B
Go
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
|
|
}
|