summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container.log.go2
-rw-r--r--libpod/logs/log.go15
2 files changed, 13 insertions, 4 deletions
diff --git a/libpod/container.log.go b/libpod/container.log.go
index 7c46dde9a..514edb8c8 100644
--- a/libpod/container.log.go
+++ b/libpod/container.log.go
@@ -41,6 +41,7 @@ func (c *Container) readFromLogFile(options *logs.LogOptions, logChannel chan *l
if len(tailLog) > 0 {
for _, nll := range tailLog {
nll.CID = c.ID()
+ nll.CName = c.Name()
if nll.Since(options.Since) {
logChannel <- nll
}
@@ -63,6 +64,7 @@ func (c *Container) readFromLogFile(options *logs.LogOptions, logChannel chan *l
partial = ""
}
nll.CID = c.ID()
+ nll.CName = c.Name()
if nll.Since(options.Since) {
logChannel <- nll
}
diff --git a/libpod/logs/log.go b/libpod/logs/log.go
index 9a7bcb5be..180b3f14b 100644
--- a/libpod/logs/log.go
+++ b/libpod/logs/log.go
@@ -35,6 +35,7 @@ type LogOptions struct {
Timestamps bool
Multi bool
WaitGroup *sync.WaitGroup
+ UseNames bool
}
// LogLine describes the information for each line of a log
@@ -44,6 +45,7 @@ type LogLine struct {
Time time.Time
Msg string
CID string
+ CName string
}
// GetLogFile returns an hp tail for a container given options
@@ -120,11 +122,16 @@ func getTailLog(path string, tail int) ([]*LogLine, error) {
func (l *LogLine) String(options *LogOptions) string {
var out string
if options.Multi {
- cid := l.CID
- if len(cid) > 12 {
- cid = cid[:12]
+ if options.UseNames {
+ cname := l.CName
+ out = fmt.Sprintf("%s ", cname)
+ } else {
+ cid := l.CID
+ if len(cid) > 12 {
+ cid = cid[:12]
+ }
+ out = fmt.Sprintf("%s ", cid)
}
- out = fmt.Sprintf("%s ", cid)
}
if options.Timestamps {
out += fmt.Sprintf("%s ", l.Time.Format(LogTimeFormat))