summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-17 07:02:52 -0400
committerGitHub <noreply@github.com>2021-09-17 07:02:52 -0400
commit9a5987cf6a7729f9d03a663dd361a37ca473da59 (patch)
tree447677216c3a88bef777cd6a452252a0314f17a7 /libpod
parentc6ae5c7961e2663ba91de7877aafe9791a80b245 (diff)
parent4216f7b7f492fee80cfc9a7f1deb608096edd890 (diff)
downloadpodman-9a5987cf6a7729f9d03a663dd361a37ca473da59.tar.gz
podman-9a5987cf6a7729f9d03a663dd361a37ca473da59.tar.bz2
podman-9a5987cf6a7729f9d03a663dd361a37ca473da59.zip
Merge pull request #11603 from rhatdan/truncate
Add no-trunc support to podman-events
Diffstat (limited to 'libpod')
-rw-r--r--libpod/events/events.go13
-rw-r--r--libpod/events/journal_linux.go2
2 files changed, 10 insertions, 5 deletions
diff --git a/libpod/events/events.go b/libpod/events/events.go
index e03215eff..16dd6424e 100644
--- a/libpod/events/events.go
+++ b/libpod/events/events.go
@@ -6,6 +6,7 @@ import (
"os"
"time"
+ "github.com/containers/storage/pkg/stringid"
"github.com/hpcloud/tail"
"github.com/pkg/errors"
)
@@ -65,11 +66,15 @@ func (e *Event) ToJSONString() (string, error) {
}
// ToHumanReadable returns human readable event as a formatted string
-func (e *Event) ToHumanReadable() string {
+func (e *Event) ToHumanReadable(truncate bool) string {
var humanFormat string
+ id := e.ID
+ if truncate {
+ id = stringid.TruncateID(id)
+ }
switch e.Type {
case Container, Pod:
- humanFormat = fmt.Sprintf("%s %s %s %s (image=%s, name=%s", e.Time, e.Type, e.Status, e.ID, e.Image, e.Name)
+ humanFormat = fmt.Sprintf("%s %s %s %s (image=%s, name=%s", e.Time, e.Type, e.Status, id, e.Image, e.Name)
// check if the container has labels and add it to the output
if len(e.Attributes) > 0 {
for k, v := range e.Attributes {
@@ -78,9 +83,9 @@ func (e *Event) ToHumanReadable() string {
}
humanFormat += ")"
case Network:
- humanFormat = fmt.Sprintf("%s %s %s %s (container=%s, name=%s)", e.Time, e.Type, e.Status, e.ID, e.ID, e.Network)
+ humanFormat = fmt.Sprintf("%s %s %s %s (container=%s, name=%s)", e.Time, e.Type, e.Status, id, id, e.Network)
case Image:
- humanFormat = fmt.Sprintf("%s %s %s %s %s", e.Time, e.Type, e.Status, e.ID, e.Name)
+ humanFormat = fmt.Sprintf("%s %s %s %s %s", e.Time, e.Type, e.Status, id, e.Name)
case System:
humanFormat = fmt.Sprintf("%s %s %s", e.Time, e.Type, e.Status)
case Volume:
diff --git a/libpod/events/journal_linux.go b/libpod/events/journal_linux.go
index a3e0d9754..3e16d8679 100644
--- a/libpod/events/journal_linux.go
+++ b/libpod/events/journal_linux.go
@@ -63,7 +63,7 @@ func (e EventJournalD) Write(ee Event) error {
case Volume:
m["PODMAN_NAME"] = ee.Name
}
- return journal.Send(string(ee.ToHumanReadable()), journal.PriInfo, m)
+ return journal.Send(string(ee.ToHumanReadable(false)), journal.PriInfo, m)
}
// Read reads events from the journal and sends qualified events to the event channel