mirror of
https://github.com/containers/podman.git
synced 2025-05-24 10:37:58 +08:00
Add event logging to libpod, even display to podman
In lipod, we now log major events that occurr. These events can be displayed using the `podman events` command. Each event contains: * Type (container, image, volume, pod...) * Status (create, rm, stop, kill, ....) * Timestamp in RFC3339Nano format * Name (if applicable) * Image (if applicable) The format of the event and the varlink endpoint are to not be considered stable until cockpit has done its enablement. Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/containers/image/types"
|
||||
@ -347,3 +348,25 @@ func StorageConfigFile() string {
|
||||
}
|
||||
return storage.DefaultConfigFile
|
||||
}
|
||||
|
||||
// ParseInputTime takes the users input and to determine if it is valid and
|
||||
// returns a time format and error. The input is compared to known time formats
|
||||
// or a duration which implies no-duration
|
||||
func ParseInputTime(inputTime string) (time.Time, error) {
|
||||
timeFormats := []string{time.RFC3339Nano, time.RFC3339, "2006-01-02T15:04:05", "2006-01-02T15:04:05.999999999",
|
||||
"2006-01-02Z07:00", "2006-01-02"}
|
||||
// iterate the supported time formats
|
||||
for _, tf := range timeFormats {
|
||||
t, err := time.Parse(tf, inputTime)
|
||||
if err == nil {
|
||||
return t, nil
|
||||
}
|
||||
}
|
||||
|
||||
// input might be a duration
|
||||
duration, err := time.ParseDuration(inputTime)
|
||||
if err != nil {
|
||||
return time.Time{}, errors.Errorf("unable to interpret time value")
|
||||
}
|
||||
return time.Now().Add(-duration), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user