aboutsummaryrefslogtreecommitdiff
path: root/pkg/adapter/containers.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-16 04:21:32 -0700
committerGitHub <noreply@github.com>2019-03-16 04:21:32 -0700
commit97fb49571828b9d206ff284ed18448f96ae877e9 (patch)
treeb1b5c7ecb963a4bc012bf0f65c287862644938b3 /pkg/adapter/containers.go
parent3384bd87c85950c245524682efa2a0f124097122 (diff)
parenta0c35c394bb95d15aeed8fcc467cb110f67fa6db (diff)
downloadpodman-97fb49571828b9d206ff284ed18448f96ae877e9.tar.gz
podman-97fb49571828b9d206ff284ed18448f96ae877e9.tar.bz2
podman-97fb49571828b9d206ff284ed18448f96ae877e9.zip
Merge pull request #2620 from baude/multilogs
display logs for multiple containers at the same time
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r--pkg/adapter/containers.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 756369196..932d209cd 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -4,7 +4,9 @@ package adapter
import (
"context"
+ "fmt"
"strconv"
+ "sync"
"syscall"
"time"
@@ -127,3 +129,28 @@ func (r *LocalRuntime) WaitOnContainers(ctx context.Context, cli *cliconfig.Wait
}
return ok, failures, err
}
+
+// Log logs one or more containers
+func (r *LocalRuntime) Log(c *cliconfig.LogsValues, options *libpod.LogOptions) error {
+ var wg sync.WaitGroup
+ options.WaitGroup = &wg
+ if len(c.InputArgs) > 1 {
+ options.Multi = true
+ }
+ logChannel := make(chan *libpod.LogLine, int(c.Tail)*len(c.InputArgs)+1)
+ containers, err := shortcuts.GetContainersByContext(false, c.Latest, c.InputArgs, r.Runtime)
+ if err != nil {
+ return err
+ }
+ if err := r.Runtime.Log(containers, options, logChannel); err != nil {
+ return err
+ }
+ go func() {
+ wg.Wait()
+ close(logChannel)
+ }()
+ for line := range logChannel {
+ fmt.Println(line.String(options))
+ }
+ return nil
+}