logtail: return correct write size from logger.Write

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/607/head
Elias Naur 4 years ago committed by Brad Fitzpatrick
parent 38b0c3eea2
commit bca9fe35ba

@ -462,5 +462,6 @@ func (l *logger) Write(buf []byte) (int, error) {
} }
} }
b := l.encode(buf) b := l.encode(buf)
return l.send(b) _, err := l.send(b)
return len(buf), err
} }

@ -32,3 +32,18 @@ func TestLoggerEncodeTextAllocs(t *testing.T) {
t.Logf("allocs = %d; want 1", int(n)) t.Logf("allocs = %d; want 1", int(n))
} }
} }
func TestLoggerWriteLength(t *testing.T) {
lg := &logger{
timeNow: time.Now,
buffer: NewMemoryBuffer(1024),
}
inBuf := []byte("some text to encode")
n, err := lg.Write(inBuf)
if err != nil {
t.Error(err)
}
if n != len(inBuf) {
t.Errorf("logger.Write wrote %d bytes, expected %d", n, len(inBuf))
}
}

Loading…
Cancel
Save