Просмотр исходного кода

Add docker compose logs --until option

Signed-off-by: Afshin Paydar <[email protected]>
Afshin Paydar 4 лет назад
Родитель
Сommit
bbaccb4339
3 измененных файлов с 6 добавлено и 1 удалено
  1. 1 0
      api/compose/api.go
  2. 4 1
      cli/cmd/compose/logs.go
  3. 1 0
      local/compose/logs.go

+ 1 - 0
api/compose/api.go

@@ -325,6 +325,7 @@ type LogOptions struct {
 	Services   []string
 	Tail       string
 	Since      string
+	Until      string
 	Follow     bool
 	Timestamps bool
 }

+ 4 - 1
cli/cmd/compose/logs.go

@@ -33,6 +33,7 @@ type logsOptions struct {
 	follow     bool
 	tail       string
 	since      string
+	until      string
 	noColor    bool
 	noPrefix   bool
 	timestamps bool
@@ -51,7 +52,8 @@ func logsCommand(p *projectOptions, contextType string, backend compose.Service)
 	}
 	flags := logsCmd.Flags()
 	flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output.")
-	flags.StringVar(&opts.since, "since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37 or 42m)")
+	flags.StringVar(&opts.since, "since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
+	flags.StringVar(&opts.until, "until", "", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
 	flags.BoolVar(&opts.noColor, "no-color", false, "Produce monochrome output.")
 	flags.BoolVar(&opts.noPrefix, "no-log-prefix", false, "Don't print prefix in logs.")
 	flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps.")
@@ -73,6 +75,7 @@ func runLogs(ctx context.Context, backend compose.Service, opts logsOptions, ser
 		Follow:     opts.follow,
 		Tail:       opts.tail,
 		Since:      opts.since,
+		Until:      opts.until,
 		Timestamps: opts.timestamps,
 	})
 }

+ 1 - 0
local/compose/logs.go

@@ -49,6 +49,7 @@ func (s *composeService) Logs(ctx context.Context, projectName string, consumer
 				ShowStderr: true,
 				Follow:     options.Follow,
 				Since:      options.Since,
+				Until:      options.Until,
 				Tail:       options.Tail,
 				Timestamps: options.Timestamps,
 			})