diff options
author | Brent Baude <bbaude@redhat.com> | 2020-04-16 08:39:34 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-04-16 12:04:46 -0500 |
commit | ba430bfe5ef65d5aa5ffa1fef0087da76aafcc35 (patch) | |
tree | 3554a8bc2a5add5feee1d008d594665f82279fb3 /libpod/container.log.go | |
parent | 8857ba20a0651e8fa71762da90d774e3aa290883 (diff) | |
download | podman-ba430bfe5ef65d5aa5ffa1fef0087da76aafcc35.tar.gz podman-ba430bfe5ef65d5aa5ffa1fef0087da76aafcc35.tar.bz2 podman-ba430bfe5ef65d5aa5ffa1fef0087da76aafcc35.zip |
podman v2 remove bloat v2
rid ourseleves of libpod references in v2 client
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/container.log.go')
-rw-r--r-- | libpod/container.log.go | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/libpod/container.log.go b/libpod/container.log.go deleted file mode 100644 index 514edb8c8..000000000 --- a/libpod/container.log.go +++ /dev/null @@ -1,75 +0,0 @@ -package libpod - -import ( - "os" - - "github.com/containers/libpod/libpod/logs" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" -) - -// Log is a runtime function that can read one or more container logs. -func (r *Runtime) Log(containers []*Container, options *logs.LogOptions, logChannel chan *logs.LogLine) error { - for _, ctr := range containers { - if err := ctr.ReadLog(options, logChannel); err != nil { - return err - } - } - return nil -} - -// ReadLog reads a containers log based on the input options and returns loglines over a channel -func (c *Container) ReadLog(options *logs.LogOptions, logChannel chan *logs.LogLine) error { - // TODO Skip sending logs until journald logs can be read - // TODO make this not a magic string - if c.LogDriver() == JournaldLogging { - return c.readFromJournal(options, logChannel) - } - return c.readFromLogFile(options, logChannel) -} - -func (c *Container) readFromLogFile(options *logs.LogOptions, logChannel chan *logs.LogLine) error { - t, tailLog, err := logs.GetLogFile(c.LogPath(), options) - if err != nil { - // If the log file does not exist, this is not fatal. - if os.IsNotExist(errors.Cause(err)) { - return nil - } - return errors.Wrapf(err, "unable to read log file %s for %s ", c.ID(), c.LogPath()) - } - options.WaitGroup.Add(1) - if len(tailLog) > 0 { - for _, nll := range tailLog { - nll.CID = c.ID() - nll.CName = c.Name() - if nll.Since(options.Since) { - logChannel <- nll - } - } - } - - go func() { - var partial string - for line := range t.Lines { - nll, err := logs.NewLogLine(line.Text) - if err != nil { - logrus.Error(err) - continue - } - if nll.Partial() { - partial += nll.Msg - continue - } else if !nll.Partial() && len(partial) > 1 { - nll.Msg = partial - partial = "" - } - nll.CID = c.ID() - nll.CName = c.Name() - if nll.Since(options.Since) { - logChannel <- nll - } - } - options.WaitGroup.Done() - }() - return nil -} |