Merge pull request #31313 from dperny/31306-fix-specify-stdoutstderr
Fix service logs API to be able to specify stream Upstream-commit: dd4a6c5affa60fda3affc2ab0e06ac4beb4c226e Component: engine
This commit is contained in:
@ -277,12 +277,22 @@ func (c *Cluster) ServiceLogs(ctx context.Context, input string, config *backend
|
||||
return err
|
||||
}
|
||||
|
||||
// set the streams we'll use
|
||||
stdStreams := []swarmapi.LogStream{}
|
||||
if config.ContainerLogsOptions.ShowStdout {
|
||||
stdStreams = append(stdStreams, swarmapi.LogStreamStdout)
|
||||
}
|
||||
if config.ContainerLogsOptions.ShowStderr {
|
||||
stdStreams = append(stdStreams, swarmapi.LogStreamStderr)
|
||||
}
|
||||
|
||||
stream, err := state.logsClient.SubscribeLogs(ctx, &swarmapi.SubscribeLogsRequest{
|
||||
Selector: &swarmapi.LogSelector{
|
||||
ServiceIDs: []string{service.ID},
|
||||
},
|
||||
Options: &swarmapi.LogSubscriptionOptions{
|
||||
Follow: config.Follow,
|
||||
Follow: config.Follow,
|
||||
Streams: stdStreams,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user