go-gelf icon indicating copy to clipboard operation
go-gelf copied to clipboard

when working with zerolog - getting a lot of "short write" errors

Open Bobby-88 opened this issue 4 years ago • 0 comments

I'm using it go-gelf with zerolog and for aly log message i'm getting short write with some debugging i've figured out that the issue is in func (w *Writer) Write(p []byte) in gelf/writer.go

May  3 15:23:15 localhost twas[4839]: writemessage succeeded 50requested:51written:50zerolog: could not write event: short write
May  3 15:23:17 localhost twas[4839]: 3:23PM DBG > 34338 _typ1=prom _typ2="processing time"
May  3 15:23:17 localhost twas[4839]: writemessage succeeded 96requested:97written:96zerolog: could not write event: short write
May  3 15:23:17 localhost twas[4839]: 3:23PM DBG debug log
May  3 15:23:17 localhost twas[4839]: writemessage succeeded 57requested:58written:57zerolog: could not write event: short write
May  3 15:23:17 localhost twas[4839]: 3:23PM DBG 12
May  3 15:23:17 localhost twas[4839]: writemessage succeeded 50requested:51written:50zerolog: could not write event: short write
May  3 15:23:19 localhost twas[4839]: 3:23PM DBG > 33720 _typ1=prom _typ2="processing time"
May  3 15:23:19 localhost twas[4839]: writemessage succeeded 96requested:97written:96zerolog: could not write event: short write
May  3 15:23:19 localhost twas[4839]: 3:23PM DBG debug log

When zerolog is requesting N bytes to write -> gelf writer is always reporting N-1 written. If i remove

p = bytes.TrimSpace(p)

then everything works ok.

Bobby-88 avatar May 03 '20 15:05 Bobby-88