Graylog2 / go-gelf

GELF library for Go
http://godoc.org/github.com/Graylog2/go-gelf/gelf
MIT License
103 stars 64 forks source link

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

Open Bobby-88 opened 4 years ago

Bobby-88 commented 4 years ago

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.