|
@@ -458,22 +458,33 @@ func (c *Cluster) ServiceLogs(ctx context.Context, selector *backend.LogSelector
|
|
for _, msg := range subscribeMsg.Messages {
|
|
for _, msg := range subscribeMsg.Messages {
|
|
// make a new message
|
|
// make a new message
|
|
m := new(backend.LogMessage)
|
|
m := new(backend.LogMessage)
|
|
- m.Attrs = make(backend.LogAttributes)
|
|
|
|
|
|
+ m.Attrs = make([]backend.LogAttr, 0, len(msg.Attrs)+3)
|
|
// add the timestamp, adding the error if it fails
|
|
// add the timestamp, adding the error if it fails
|
|
m.Timestamp, err = gogotypes.TimestampFromProto(msg.Timestamp)
|
|
m.Timestamp, err = gogotypes.TimestampFromProto(msg.Timestamp)
|
|
if err != nil {
|
|
if err != nil {
|
|
m.Err = err
|
|
m.Err = err
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ nodeKey := contextPrefix + ".node.id"
|
|
|
|
+ serviceKey := contextPrefix + ".service.id"
|
|
|
|
+ taskKey := contextPrefix + ".task.id"
|
|
|
|
+
|
|
// copy over all of the details
|
|
// copy over all of the details
|
|
for _, d := range msg.Attrs {
|
|
for _, d := range msg.Attrs {
|
|
- m.Attrs[d.Key] = d.Value
|
|
|
|
|
|
+ switch d.Key {
|
|
|
|
+ case nodeKey, serviceKey, taskKey:
|
|
|
|
+ // we have the final say over context details (in case there
|
|
|
|
+ // is a conflict (if the user added a detail with a context's
|
|
|
|
+ // key for some reason))
|
|
|
|
+ default:
|
|
|
|
+ m.Attrs = append(m.Attrs, backend.LogAttr{Key: d.Key, Value: d.Value})
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- // we have the final say over context details (in case there
|
|
|
|
- // is a conflict (if the user added a detail with a context's
|
|
|
|
- // key for some reason))
|
|
|
|
- m.Attrs[contextPrefix+".node.id"] = msg.Context.NodeID
|
|
|
|
- m.Attrs[contextPrefix+".service.id"] = msg.Context.ServiceID
|
|
|
|
- m.Attrs[contextPrefix+".task.id"] = msg.Context.TaskID
|
|
|
|
|
|
+ m.Attrs = append(m.Attrs,
|
|
|
|
+ backend.LogAttr{Key: nodeKey, Value: msg.Context.NodeID},
|
|
|
|
+ backend.LogAttr{Key: serviceKey, Value: msg.Context.ServiceID},
|
|
|
|
+ backend.LogAttr{Key: taskKey, Value: msg.Context.TaskID},
|
|
|
|
+ )
|
|
|
|
|
|
switch msg.Stream {
|
|
switch msg.Stream {
|
|
case swarmapi.LogStreamStdout:
|
|
case swarmapi.LogStreamStdout:
|