Merge pull request #2348 from SvenDowideit/2328-docker-events-since-date-string
Use string timestamp for docker events -since
This commit is contained in:
commit
4f8b6c3283
2 changed files with 32 additions and 2 deletions
14
commands.go
14
commands.go
|
@ -1387,7 +1387,7 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
|
|||
|
||||
func (cli *DockerCli) CmdEvents(args ...string) error {
|
||||
cmd := Subcmd("events", "[OPTIONS]", "Get real time events from the server")
|
||||
since := cmd.String("since", "", "Show events previously created (used for polling).")
|
||||
since := cmd.String("since", "", "Show previously created events and then stream.")
|
||||
if err := cmd.Parse(args); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -1399,7 +1399,17 @@ func (cli *DockerCli) CmdEvents(args ...string) error {
|
|||
|
||||
v := url.Values{}
|
||||
if *since != "" {
|
||||
v.Set("since", *since)
|
||||
loc := time.FixedZone(time.Now().Zone())
|
||||
format := "2006-01-02 15:04:05 -0700 MST"
|
||||
if len(*since) < len(format) {
|
||||
format = format[:len(*since)]
|
||||
}
|
||||
|
||||
if t, err := time.ParseInLocation(format, *since, loc); err == nil {
|
||||
v.Set("since", strconv.FormatInt(t.Unix(), 10))
|
||||
} else {
|
||||
v.Set("since", *since)
|
||||
}
|
||||
}
|
||||
|
||||
if err := cli.stream("GET", "/events?"+v.Encode(), nil, cli.out, nil); err != nil {
|
||||
|
|
|
@ -245,6 +245,9 @@ Full -run example
|
|||
Usage: docker events
|
||||
|
||||
Get real time events from the server
|
||||
|
||||
-since="": Show previously created events and then stream.
|
||||
(either seconds since epoch, or date string as below)
|
||||
|
||||
.. _cli_events_example:
|
||||
|
||||
|
@ -277,6 +280,23 @@ Shell 1: (Again .. now showing events)
|
|||
[2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
|
||||
[2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
|
||||
|
||||
Show events in the past from a specified time
|
||||
.............................................
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ sudo docker events -since 1378216169
|
||||
[2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
|
||||
[2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
|
||||
|
||||
$ sudo docker events -since '2013-09-03'
|
||||
[2013-09-03 15:49:26 +0200 CEST] 4386fb97867d: (from 12de384bfb10) start
|
||||
[2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
|
||||
[2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
|
||||
|
||||
$ sudo docker events -since '2013-09-03 15:49:29 +0200 CEST'
|
||||
[2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) die
|
||||
[2013-09-03 15:49:29 +0200 CEST] 4386fb97867d: (from 12de384bfb10) stop
|
||||
|
||||
.. _cli_export:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue