As docker logs defines --since option to limit the amount of logs to retrieve from container's history

This changes will add docker compose logs --since option

Signed-off-by: Afshin Paydar <afshin.paydar@binary.com>
This commit is contained in:
Afshin Paydar 2021-06-15 00:14:30 +08:00
parent f06baeef20
commit 3976abcdc1
3 changed files with 5 additions and 0 deletions

View File

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

View File

@ -32,6 +32,7 @@ type logsOptions struct {
composeOptions composeOptions
follow bool follow bool
tail string tail string
since string
noColor bool noColor bool
noPrefix bool noPrefix bool
timestamps bool timestamps bool
@ -50,6 +51,7 @@ func logsCommand(p *projectOptions, contextType string, backend compose.Service)
} }
flags := logsCmd.Flags() flags := logsCmd.Flags()
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 (e.g. 2013-01-02T13:23:37 or 42m)")
flags.BoolVar(&opts.noColor, "no-color", false, "Produce monochrome output.") 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.BoolVar(&opts.noPrefix, "no-log-prefix", false, "Don't print prefix in logs.")
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps.") flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps.")
@ -70,6 +72,7 @@ func runLogs(ctx context.Context, backend compose.Service, opts logsOptions, ser
Services: services, Services: services,
Follow: opts.follow, Follow: opts.follow,
Tail: opts.tail, Tail: opts.tail,
Since: opts.since,
Timestamps: opts.timestamps, Timestamps: opts.timestamps,
}) })
} }

View File

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