From 3cda347b3de0cbaa9bfe814a7052a7b9847bbceb Mon Sep 17 00:00:00 2001 From: Drew Erny Date: Wed, 8 Mar 2017 16:28:21 -0800 Subject: [PATCH] Fixed concerns, updated, and rebased PR. Signed-off-by: Drew Erny --- command/service/logs.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/command/service/logs.go b/command/service/logs.go index 2f3e6ca90d..5e7cce3e2c 100644 --- a/command/service/logs.go +++ b/command/service/logs.go @@ -23,11 +23,10 @@ import ( type logsOptions struct { noResolve bool noTrunc bool - noIDs bool + noTaskIDs bool follow bool since string timestamps bool - details bool tail string service string @@ -50,11 +49,10 @@ func newLogsCommand(dockerCli *command.DockerCli) *cobra.Command { flags := cmd.Flags() flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output") - flags.BoolVar(&opts.noIDs, "no-ids", false, "Do not include task IDs") + flags.BoolVar(&opts.noTaskIDs, "no-task-ids", false, "Do not include task IDs") flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output") flags.StringVar(&opts.since, "since", "", "Show logs since timestamp") flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps") - flags.BoolVar(&opts.details, "details", false, "Show extra details provided to logs") flags.StringVar(&opts.tail, "tail", "all", "Number of lines to show from the end of the logs") return cmd } @@ -69,7 +67,6 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { Timestamps: opts.timestamps, Follow: opts.follow, Tail: opts.tail, - Details: opts.details, } client := dockerCli.Client() @@ -86,10 +83,12 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { defer responseBody.Close() var replicas uint64 + padding := 1 if service.Spec.Mode.Replicated != nil && service.Spec.Mode.Replicated.Replicas != nil { + // if replicas are initialized, figure out if we need to pad them replicas = *service.Spec.Mode.Replicated.Replicas + padding = len(strconv.FormatUint(replicas, 10)) } - padding := len(strconv.FormatUint(replicas, 10)) taskFormatter := newTaskFormatter(client, opts, padding) @@ -141,7 +140,7 @@ func (f *taskFormatter) format(ctx context.Context, logCtx logContext) (string, } taskName := fmt.Sprintf("%s.%d", serviceName, task.Slot) - if !f.opts.noIDs { + if !f.opts.noTaskIDs { if f.opts.noTrunc { taskName += fmt.Sprintf(".%s", task.ID) } else {