mirror of https://github.com/docker/cli.git
Fixed concerns, updated, and rebased PR.
Signed-off-by: Drew Erny <drew.erny@docker.com>
This commit is contained in:
parent
1d379b9691
commit
3cda347b3d
|
@ -23,11 +23,10 @@ import (
|
||||||
type logsOptions struct {
|
type logsOptions struct {
|
||||||
noResolve bool
|
noResolve bool
|
||||||
noTrunc bool
|
noTrunc bool
|
||||||
noIDs bool
|
noTaskIDs bool
|
||||||
follow bool
|
follow bool
|
||||||
since string
|
since string
|
||||||
timestamps bool
|
timestamps bool
|
||||||
details bool
|
|
||||||
tail string
|
tail string
|
||||||
|
|
||||||
service string
|
service string
|
||||||
|
@ -50,11 +49,10 @@ func newLogsCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names")
|
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.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.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output")
|
||||||
flags.StringVar(&opts.since, "since", "", "Show logs since timestamp")
|
flags.StringVar(&opts.since, "since", "", "Show logs since timestamp")
|
||||||
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps")
|
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")
|
flags.StringVar(&opts.tail, "tail", "all", "Number of lines to show from the end of the logs")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -69,7 +67,6 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error {
|
||||||
Timestamps: opts.timestamps,
|
Timestamps: opts.timestamps,
|
||||||
Follow: opts.follow,
|
Follow: opts.follow,
|
||||||
Tail: opts.tail,
|
Tail: opts.tail,
|
||||||
Details: opts.details,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
@ -86,10 +83,12 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error {
|
||||||
defer responseBody.Close()
|
defer responseBody.Close()
|
||||||
|
|
||||||
var replicas uint64
|
var replicas uint64
|
||||||
|
padding := 1
|
||||||
if service.Spec.Mode.Replicated != nil && service.Spec.Mode.Replicated.Replicas != nil {
|
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
|
replicas = *service.Spec.Mode.Replicated.Replicas
|
||||||
|
padding = len(strconv.FormatUint(replicas, 10))
|
||||||
}
|
}
|
||||||
padding := len(strconv.FormatUint(replicas, 10))
|
|
||||||
|
|
||||||
taskFormatter := newTaskFormatter(client, opts, padding)
|
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)
|
taskName := fmt.Sprintf("%s.%d", serviceName, task.Slot)
|
||||||
if !f.opts.noIDs {
|
if !f.opts.noTaskIDs {
|
||||||
if f.opts.noTrunc {
|
if f.opts.noTrunc {
|
||||||
taskName += fmt.Sprintf(".%s", task.ID)
|
taskName += fmt.Sprintf(".%s", task.ID)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue