Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clireporter/prefixedwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func (w *PrefixedWriter) Write(p []byte) (n int, err error) {
h.Write([]byte(w.Prefix))
c := colors[int(h.Sum32())%len(colors)]

// If we format p as a JSON, it's possible that the number of bytes can
// change.
// The writer expects us to return the original length of p.
origLen := len(p)
var jsonObj interface{}
err = json.Unmarshal([]byte(p), &jsonObj)
if err == nil {
Expand All @@ -106,7 +110,7 @@ func (w *PrefixedWriter) Write(p []byte) (n int, err error) {
}

_, err = w.Writer.Write([]byte(strings.Join(prefixed, "\n") + "\n"))
return len(p), err
return origLen, err
}

func leftPad(s string, l int) string {
Expand Down