From 6d9b1e4b8e7f72981cabcf576a8771ff458c0385 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 12 Nov 2021 09:52:28 -0500 Subject: Fix partial log line handling with journald log driver Patch originally by Paul Holzinger (sourced from [1]). This is necessary to get the tests to pass in order to include a batch of other, related journald fixes in `podman logs`. [1] https://github.com/containers/podman/pull/12274#issuecomment-967168173 Signed-off-by: Matthew Heon --- libpod/container_log_linux.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go index 4029d0af7..b6b780bab 100644 --- a/libpod/container_log_linux.go +++ b/libpod/container_log_linux.go @@ -140,6 +140,7 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption doTail = false } lastReadCursor := "" + partial := "" for { select { case <-ctx.Done(): @@ -229,6 +230,12 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption logrus.Errorf("Failed parse log line: %v", err) return } + if logLine.Partial() { + partial += logLine.Msg + continue + } + logLine.Msg = partial + logLine.Msg + partial = "" if doTail { tailQueue = append(tailQueue, logLine) continue -- cgit v1.2.3-54-g00ecf