diff options
author | Paul Holzinger <paul.holzinger@web.de> | 2020-12-10 17:39:57 +0100 |
---|---|---|
committer | Paul Holzinger <paul.holzinger@web.de> | 2020-12-10 22:24:43 +0100 |
commit | ba545c49a216d20be83bdfb0357a4d5f0abe6800 (patch) | |
tree | 8b00fa4a88408ed594f2b5e04116b7bcdd933b67 /libpod | |
parent | 2bb149034bd67dd4027768863fed2fce853833ae (diff) | |
download | podman-ba545c49a216d20be83bdfb0357a4d5f0abe6800.tar.gz podman-ba545c49a216d20be83bdfb0357a4d5f0abe6800.tar.bz2 podman-ba545c49a216d20be83bdfb0357a4d5f0abe6800.zip |
podman logs honor stderr correctly
Make the ContainerLogsOptions support two io.Writers,
one for stdout and the other for stderr. The logline already
includes the information to which Writer it has to be written.
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/logs/log.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libpod/logs/log.go b/libpod/logs/log.go index a9554088b..d3d83747f 100644 --- a/libpod/logs/log.go +++ b/libpod/logs/log.go @@ -210,3 +210,19 @@ func NewLogLine(line string) (*LogLine, error) { func (l *LogLine) Partial() bool { return l.ParseLogType == PartialLogType } + +func (l *LogLine) Write(stdout io.Writer, stderr io.Writer, logOpts *LogOptions) { + switch l.Device { + case "stdout": + if stdout != nil { + fmt.Fprintln(stdout, l.String(logOpts)) + } + case "stderr": + if stderr != nil { + fmt.Fprintln(stderr, l.String(logOpts)) + } + default: + // Warn the user if the device type does not match. Most likely the file is corrupted. + logrus.Warnf("unknown Device type '%s' in log file from Container %s", l.Device, l.CID) + } +} |