Skip to content

Commit e7445d4

Browse files
committed
Fix logging channel messages.
Having '\n' character in between message field is braking SSE specification and client could not parse correctly such events Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
1 parent e9f4b73 commit e7445d4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/crc/api/events/log_stream.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package events
22

33
import (
4+
"bytes"
5+
46
"github.com/crc-org/crc/v2/pkg/crc/logging"
57
"github.com/r3labs/sse/v2"
68
"github.com/sirupsen/logrus"
@@ -56,7 +58,10 @@ func (s *streamHook) Fire(entry *logrus.Entry) error {
5658
return err
5759
}
5860

59-
s.server.Publish(LOGS, &sse.Event{Event: []byte(LOGS), Data: line})
61+
// remove "Line Feed"("\n") character which add was added by json.Encoder
62+
line = bytes.TrimRight(line, "\n")
63+
64+
s.server.Publish(Logs, &sse.Event{Event: []byte(Logs), Data: line})
6065
return nil
6166
}
6267

0 commit comments

Comments
 (0)