splunk_logger: move environment hook to splunk_logger pt1
this has to be in two steps: - duplicate to splunk_logger first - change and use the reference from within go.mod and the main code
This commit is contained in:
parent
812b331743
commit
0239db5323
2 changed files with 56 additions and 0 deletions
26
pkg/splunk_logger/environment_hook.go
Normal file
26
pkg/splunk_logger/environment_hook.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue