Skip to content

Commit

Permalink
fix(k8s/log): corerct line breaks in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sarub0b0 committed May 29, 2023
1 parent 149bc60 commit a4b1102
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/event/kubernetes/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit a4b1102

Please sign in to comment.