Skip to content

Commit

Permalink
Fix logging channel messages.
Browse files Browse the repository at this point in the history
Having '\n' character in between message field is braking SSE specification and client could not parse correctly such events

Signed-off-by: Yevhen Vydolob <[email protected]>
  • Loading branch information
evidolob committed Apr 9, 2024
1 parent e9f4b73 commit e7445d4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/crc/api/events/log_stream.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package events

import (
"bytes"

"github.com/crc-org/crc/v2/pkg/crc/logging"
"github.com/r3labs/sse/v2"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -56,7 +58,10 @@ func (s *streamHook) Fire(entry *logrus.Entry) error {
return err
}

s.server.Publish(LOGS, &sse.Event{Event: []byte(LOGS), Data: line})
// remove "Line Feed"("\n") character which add was added by json.Encoder
line = bytes.TrimRight(line, "\n")

s.server.Publish(Logs, &sse.Event{Event: []byte(Logs), Data: line})
return nil
}

Expand Down

0 comments on commit e7445d4

Please sign in to comment.