Commit 2134365c authored by Brian Tiger Chow's avatar Brian Tiger Chow

docs(eventlog)

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 25c98e8e
...@@ -63,17 +63,24 @@ type eventLogger struct { ...@@ -63,17 +63,24 @@ type eventLogger struct {
} }
func (el *eventLogger) Event(ctx context.Context, event string, metadata ...Loggable) { func (el *eventLogger) Event(ctx context.Context, event string, metadata ...Loggable) {
// get any existing metadata from the context
existing, err := MetadataFromContext(ctx) existing, err := MetadataFromContext(ctx)
if err != nil { if err != nil {
existing = Metadata{} existing = Metadata{}
} }
// accumulate metadata
accum := existing accum := existing
for _, datum := range metadata { for _, datum := range metadata {
accum = DeepMerge(accum, datum.Loggable()) accum = DeepMerge(accum, datum.Loggable())
} }
// apply final attributes to reserved keys
accum["event"] = event accum["event"] = event
accum["system"] = el.system accum["system"] = el.system
accum["time"] = util.FormatRFC3339(time.Now()) accum["time"] = util.FormatRFC3339(time.Now())
// TODO roll our own event logger
logrus.WithFields(map[string]interface{}(accum)).Info(event) logrus.WithFields(map[string]interface{}(accum)).Info(event)
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment