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

Method Flush

log/buffered.go:49–65  ·  view source on GitHub ↗

Flush forces the buffer to be written to the underlying writer.

()

Source from the content-addressed store, hash-verified

47
48// Flush forces the buffer to be written to the underlying writer.
49func (l *BufferedLogger) Flush() error {
50 // reset the counter
51 sz := l.entries.Swap(0)
52 if sz <= 0 {
53 return nil
54 }
55
56 // WriteTo() calls Reset() on the underlying buffer, so it's not needed here
57 _, err := l.buf.WriteTo(l.w)
58
59 // only call OnFlush callback if write was successful
60 if err == nil && l.onFlush != nil {
61 l.onFlush(sz)
62 }
63
64 return err
65}
66
67type BufferedLoggerOption func(*BufferedLogger)
68

Callers 3

BenchmarkBufferedFunction · 0.95
TestOnFlushCallbackFunction · 0.95
WriteMethod · 0.95

Calls 2

SwapMethod · 0.45
WriteToMethod · 0.45

Tested by 2

BenchmarkBufferedFunction · 0.76
TestOnFlushCallbackFunction · 0.76