Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 3976abc

Browse files
author
Afshin Paydar
committed
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 <[email protected]>
1 parent f06baee commit 3976abc

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

api/compose/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ type ServiceStatus struct {
324324
type LogOptions struct {
325325
Services []string
326326
Tail string
327+
Since string
327328
Follow bool
328329
Timestamps bool
329330
}

cli/cmd/compose/logs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type logsOptions struct {
3232
composeOptions
3333
follow bool
3434
tail string
35+
since string
3536
noColor bool
3637
noPrefix bool
3738
timestamps bool
@@ -50,6 +51,7 @@ func logsCommand(p *projectOptions, contextType string, backend compose.Service)
5051
}
5152
flags := logsCmd.Flags()
5253
flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output.")
54+
flags.StringVar(&opts.since, "since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37 or 42m)")
5355
flags.BoolVar(&opts.noColor, "no-color", false, "Produce monochrome output.")
5456
flags.BoolVar(&opts.noPrefix, "no-log-prefix", false, "Don't print prefix in logs.")
5557
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps.")
@@ -70,6 +72,7 @@ func runLogs(ctx context.Context, backend compose.Service, opts logsOptions, ser
7072
Services: services,
7173
Follow: opts.follow,
7274
Tail: opts.tail,
75+
Since: opts.since,
7376
Timestamps: opts.timestamps,
7477
})
7578
}

local/compose/logs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (s *composeService) Logs(ctx context.Context, projectName string, consumer
4848
ShowStdout: true,
4949
ShowStderr: true,
5050
Follow: options.Follow,
51+
Since: options.Since,
5152
Tail: options.Tail,
5253
Timestamps: options.Timestamps,
5354
})

0 commit comments

Comments
 (0)