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>
This commit is contained in:
parent
b0c6fd961b
commit
9892ab0af7
3 changed files with 29 additions and 4 deletions
22
timeutils/utils.go
Normal file
22
timeutils/utils.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue