cloudapi: propagate operation/external id
Signed-off-by: Lukas Zapletal <lzap+git@redhat.com>
This commit is contained in:
parent
f3c0daebbf
commit
5ce8f65a58
8 changed files with 169 additions and 41 deletions
33
internal/common/context_hook.go
Normal file
33
internal/common/context_hook.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type ContextHook struct{}
|
||||
|
||||
func (h *ContextHook) Levels() []logrus.Level {
|
||||
return []logrus.Level{
|
||||
logrus.DebugLevel,
|
||||
logrus.InfoLevel,
|
||||
logrus.WarnLevel,
|
||||
logrus.ErrorLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.PanicLevel,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *ContextHook) Fire(e *logrus.Entry) error {
|
||||
if e.Context == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if val := e.Context.Value(operationIDKeyCtx); val != nil {
|
||||
e.Data["operation_id"] = val
|
||||
}
|
||||
if val := e.Context.Value(externalIDKeyCtx); val != nil {
|
||||
e.Data["external_id"] = val
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue