prettyPrintEvent prints all types of event information. Each output includes the event type, actor id, name and action. Actor attributes are printed at the end if the actor has any.
(out io.Writer, event events.Message)
| 124 | // Each output includes the event type, actor id, name and action. |
| 125 | // Actor attributes are printed at the end if the actor has any. |
| 126 | func prettyPrintEvent(out io.Writer, event events.Message) error { |
| 127 | if event.TimeNano != 0 { |
| 128 | _, _ = fmt.Fprintf(out, "%s ", time.Unix(0, event.TimeNano).Format(rfc3339NanoFixed)) |
| 129 | } else if event.Time != 0 { |
| 130 | _, _ = fmt.Fprintf(out, "%s ", time.Unix(event.Time, 0).Format(rfc3339NanoFixed)) |
| 131 | } |
| 132 | |
| 133 | _, _ = fmt.Fprintf(out, "%s %s %s", event.Type, event.Action, event.Actor.ID) |
| 134 | |
| 135 | if len(event.Actor.Attributes) > 0 { |
| 136 | keys := make([]string, 0, len(event.Actor.Attributes)) |
| 137 | for k := range event.Actor.Attributes { |
| 138 | keys = append(keys, k) |
| 139 | } |
| 140 | sort.Strings(keys) |
| 141 | attrs := make([]string, 0, len(keys)) |
| 142 | for _, k := range keys { |
| 143 | v := event.Actor.Attributes[k] |
| 144 | attrs = append(attrs, k+"="+v) |
| 145 | } |
| 146 | _, _ = fmt.Fprintf(out, " (%s)", strings.Join(attrs, ", ")) |
| 147 | } |
| 148 | _, _ = fmt.Fprint(out, "\n") |
| 149 | return nil |
| 150 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…