MCPcopy
hub / github.com/grafana/dskit / Write

Method Write

log/buffered.go:33–46  ·  view source on GitHub ↗

Write writes the given bytes to the line buffer, and increments the entries counter. If the buffer is full (entries == cap), it will be flushed, and the entries counter reset.

(p []byte)

Source from the content-addressed store, hash-verified

31// Write writes the given bytes to the line buffer, and increments the entries counter.
32// If the buffer is full (entries == cap), it will be flushed, and the entries counter reset.
33func (l *BufferedLogger) Write(p []byte) (n int, err error) {
34 // when we've filled the buffer, flush it
35 if l.Size() >= l.cap {
36 // Flush resets the size to 0
37 if err := l.Flush(); err != nil {
38 l.buf.Reset()
39 return 0, err
40 }
41 }
42
43 l.entries.Inc()
44
45 return l.buf.Write(p)
46}
47
48// Flush forces the buffer to be written to the underlying writer.
49func (l *BufferedLogger) Flush() error {

Calls 3

SizeMethod · 0.95
FlushMethod · 0.95
ResetMethod · 0.45