From a92995bc1462058401c64a153ccdf07bf40ee5da Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Tue, 14 Apr 2015 04:36:12 +0000 Subject: [PATCH] Add --since argument to docker logs cmd Added --since argument to `docker logs` command. Accept unix timestamps and shows logs only created after the specified date. Default value is 0 and passing default value or not specifying the value in the request causes parameter to be ignored (behavior prior to this change). Signed-off-by: Ahmet Alp Balkan --- contrib/completion/bash/docker | 2 +- contrib/completion/fish/docker.fish | 1 + contrib/completion/zsh/_docker | 1 + docs/sources/reference/commandline/cli.md | 5 +++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 325e50c000..64c53f6de6 100755 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -593,7 +593,7 @@ _docker_logs() { case "$cur" in -*) - COMPREPLY=( $( compgen -W "--follow -f --help --tail --timestamps -t" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "--follow -f --help --since --tail --timestamps -t" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--tail') diff --git a/contrib/completion/fish/docker.fish b/contrib/completion/fish/docker.fish index 42f33e3858..79f7ed4bad 100644 --- a/contrib/completion/fish/docker.fish +++ b/contrib/completion/fish/docker.fish @@ -233,6 +233,7 @@ complete -c docker -f -n '__fish_docker_no_subcommand' -a logs -d 'Fetch the log complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -s f -l follow -d 'Follow log output' complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -l help -d 'Print usage' complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -s t -l timestamps -d 'Show timestamps' +complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -l since -d 'Show logs since timestamp' complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -l tail -d 'Output the specified number of lines at the end of logs (defaults to all logs)' complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -a '(__fish_print_docker_containers running)' -d "Container" diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index 3cff8fbbb6..abd666313e 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -305,6 +305,7 @@ __docker_subcommand () { (logs) _arguments \ {-f,--follow}'[Follow log output]' \ + '-s,--since[Show logs since timestamp]' \ {-t,--timestamps}'[Show timestamps]' \ '--tail=-[Output the last K lines]:lines:(1 10 20 50 all)' \ '*:containers:__docker_containers' diff --git a/docs/sources/reference/commandline/cli.md b/docs/sources/reference/commandline/cli.md index e5f761b881..d9d1eee0f8 100644 --- a/docs/sources/reference/commandline/cli.md +++ b/docs/sources/reference/commandline/cli.md @@ -1632,6 +1632,7 @@ For example: Fetch the logs of a container -f, --follow=false Follow log output + --since="" Show logs since timestamp -t, --timestamps=false Show timestamps --tail="all" Number of lines to show from the end of the logs @@ -1651,6 +1652,10 @@ timestamp, for example `2014-09-16T06:17:46.000000000Z`, to each log entry. To ensure that the timestamps for are aligned the nano-second part of the timestamp will be padded with zero when necessary. +The `--since` option shows logs of a container generated only after +the given date, specified as RFC 3339 or UNIX timestamp. The `--since` option +can be combined with the `--follow` and `--tail` options. + ## pause Usage: docker pause CONTAINER [CONTAINER...]