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 <ahmetalpbalkan@gmail.com>
Upstream-commit: cb9a6b9aed1577bb5590300125d05d9b1c201c16
Component: engine
This commit is contained in:
Ahmet Alp Balkan
2015-04-14 04:36:12 +00:00
parent a40ebffc52
commit 365c18080f
15 changed files with 154 additions and 25 deletions

View File

@ -0,0 +1,22 @@
package timeutils
import (
"strconv"
"time"
)
// GetTimestamp tries to parse given string as RFC3339 time
// or Unix timestamp, if successful returns a Unix timestamp
// as string otherwise returns value back.
func GetTimestamp(value string) string {
format := RFC3339NanoFixed
loc := time.FixedZone(time.Now().Zone())
if len(value) < len(format) {
format = format[:len(value)]
}
t, err := time.ParseInLocation(format, value, loc)
if err != nil {
return value
}
return strconv.FormatInt(t.Unix(), 10)
}