splunk_logger: move environment hook to splunk_logger pt2

for reusability also in image-builder
This commit is contained in:
Florian Schüller 2024-08-14 13:01:02 +02:00 committed by Florian Schüller
parent 43c6bc7abc
commit a4068b328d
6 changed files with 7 additions and 37 deletions

View file

@ -0,0 +1,26 @@
package logger
import (
"github.com/sirupsen/logrus"
)
type EnvironmentHook struct {
Channel string
}
func (h *EnvironmentHook) Levels() []logrus.Level {
return []logrus.Level{
logrus.DebugLevel,
logrus.InfoLevel,
logrus.WarnLevel,
logrus.ErrorLevel,
logrus.FatalLevel,
logrus.PanicLevel,
}
}
func (h *EnvironmentHook) Fire(e *logrus.Entry) error {
e.Data["channel"] = h.Channel
return nil
}