YTSFlix_Go/vendor/github.com/asticode/go-astilog/hooks.go
2018-11-04 15:58:15 +01:00

26 lines
384 B
Go

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
}