From 1d2d461e402fa4da404b8efe00eb1f9fce7befef Mon Sep 17 00:00:00 2001 From: Drew Erny Date: Thu, 23 Feb 2017 15:09:09 -0800 Subject: [PATCH] Fix service logs API to be able to specify stream Before this change, doing service logs was just tossing the stream selectors and always using the default (both streams). This change adds a check for which streams the user wants and only includes those. Fixes #31306 Signed-off-by: Drew Erny Upstream-commit: f63c62ce70d6ed4706dbde43feb22c6004c32061 Component: engine --- components/engine/daemon/cluster/services.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/engine/daemon/cluster/services.go b/components/engine/daemon/cluster/services.go index 3f934131d1..a80730c687 100644 --- a/components/engine/daemon/cluster/services.go +++ b/components/engine/daemon/cluster/services.go @@ -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 {