YTSFlix_Go/vendor/github.com/asticode/go-astilog/hooks.go

26 lines
384 B
Go
Raw Normal View History

2018-11-04 14:58:15 +00:00
package astilog
import "github.com/sirupsen/logrus"
type withFieldHook struct {
k, v string
}
func newWithFieldHook(k, v string) *withFieldHook {
return &withFieldHook{
k: k,
v: v,
}
}
func (h *withFieldHook) Fire(e *logrus.Entry) error {
if len(h.v) > 0 {
e.Data[h.k] = h.v
}
return nil
}
func (h *withFieldHook) Levels() []logrus.Level {
return logrus.AllLevels
}