From a4b1102e19a674b38876b2b8af190f05e7dc91e6 Mon Sep 17 00:00:00 2001 From: kosay Date: Tue, 30 May 2023 00:29:41 +0900 Subject: [PATCH] fix(k8s/log): corerct line breaks in logs --- src/event/kubernetes/log.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/event/kubernetes/log.rs b/src/event/kubernetes/log.rs index 127dcb03..05bbcac8 100644 --- a/src/event/kubernetes/log.rs +++ b/src/event/kubernetes/log.rs @@ -828,17 +828,30 @@ impl Worker for FetchLogStream { let mut logs = self.pod_api.log_stream(&self.pod_name, &lp).await?.boxed(); - while let Some(line) = logs.try_next().await? { + while let Some(bytes) = logs.try_next().await? { let mut buf = self.buf.write().await; - buf.push(format!("{}{}", prefix, String::from_utf8_lossy(&line))); + + let logs = String::from_utf8_lossy(&bytes); logger!( debug, "Container log stream [{}:{}] - {}", self.pod_name, self.container_name, - String::from_utf8_lossy(&line) + logs ); + + for line in logs.lines() { + buf.push(format!("{}{}", prefix, line)); + + logger!( + debug, + "Container log stream [{}:{}] - {}", + self.pod_name, + self.container_name, + line + ); + } } logger!(