Skip to content

Commit

Permalink
Fixes sever sent events formatting for logs api
Browse files Browse the repository at this point in the history
  • Loading branch information
frechg committed Oct 16, 2024
1 parent e658ed6 commit 8cef626
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions local-interchain/interchain/handlers/log_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (ls *LogStream) StreamLogs(w http.ResponseWriter, r *http.Request) {
// print last out to the user on request (i.e. new connections)
tail := TailFile(ls.logger, ls.fName, tailLines)
for _, line := range tail {
fmt.Fprintf(w, "%s\n", line)
fmt.Fprintf(w, "data: %s\n\n", line)
}
flusher.Flush()

Expand All @@ -79,7 +79,7 @@ func (ls *LogStream) StreamLogs(w http.ResponseWriter, r *http.Request) {
line, err := reader.ReadString('\n')
if err == nil {
// Send the log line to the client
fmt.Fprintf(w, "%s\n", line)
fmt.Fprintf(w, "data: %s\n\n", line)
flusher.Flush() // Send to client immediately
} else {
// If no new log is available, wait for a short period before retrying
Expand Down

0 comments on commit 8cef626

Please sign in to comment.