Skip to content

Commit

Permalink
more machine readable log format
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
Signed-off-by: Fabian von Feilitzsch <fabian@fabianism.us>
  • Loading branch information
fabianvf and Eric Stroczynski committed Apr 27, 2021
1 parent e0a54cf commit cdd8834
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/ansible/handler/logging_enqueue_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ func (h LoggingEnqueueRequestForObject) Generic(e event.GenericEvent, q workqueu
}

func (h LoggingEnqueueRequestForObject) logEvent(eventType string, object client.Object) {
objectNs := object.GetNamespace()
if objectNs == "" {
objectNs = "<nil>"
kvs := []string{
"Event type", eventType,
"GroupVersionKind", object.GetObjectKind().GroupVersionKind().String(),
"Name", object.GetName(),
}
log.Info(fmt.Sprintf("Received %s event for GVK %s with name %s in namespace %s",
eventType,
object.GetObjectKind().GroupVersionKind().String(),
object.GetName(), objectNs))
if objectNs := object.GetNamespace(); objectNs != "" {
kvs = append(kvs, "Namespace", objectNs)
}
log.Info("Metrics handler event", kvs...))
}

0 comments on commit cdd8834

Please sign in to comment.