logrus: add deployment channel as field to the logs
This commit is contained in:
parent
2da3a73308
commit
9006836afc
5 changed files with 80 additions and 11 deletions
26
internal/common/environment_hook.go
Normal file
26
internal/common/environment_hook.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package common
|
||||
|
||||
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