Documentation
¶
Overview ¶
Package logbuffer implements a fixed-size in-memory ring buffer for line-separated logs. It implements io.Writer and splits the data into lines. The lines are kept in a ring where the oldest are overwritten once it's full. It allows retrieval of the last n lines. There is a built-in line length limit to bound the memory usage at maxLineLength * size.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Line ¶
Line is a line stored in the log buffer - a string, that has been perhaps truncated (due to exceeded limits).
func LineFromLogProto ¶
func LineFromLogProto(raw *lpb.LogEntry_Raw) (*Line, error)
LineFromLogProto converts a Logging-specific protobuf message back into a Line.
func (*Line) ProtoLog ¶
func (l *Line) ProtoLog() *lpb.LogEntry_Raw
ProtoLog returns a Logging-specific protobuf structure.
type LineBuffer ¶
type LineBuffer struct {
// contains filtered or unexported fields
}
LineBuffer is a io.WriteCloser that will call a given callback every time a line is completed.
func NewLineBuffer ¶
func NewLineBuffer(maxLineLength int, cb LineBufferCallback) *LineBuffer
NewLineBuffer creates a new LineBuffer with a given line length limit and callback.
func (*LineBuffer) Close ¶
func (l *LineBuffer) Close() error
Close will emit any leftover data in the buffer to the callback. Subsequent calls to Write will fail. Subsequent calls to Close will also fail.
func (*LineBuffer) Sync ¶
func (l *LineBuffer) Sync() error
type LineBufferCallback ¶
type LineBufferCallback func(*Line)
LineBufferCallback is a callback that will get called any time the line is completed. The function must not cause another write to the LineBuffer, or the program will deadlock.
type LogBuffer ¶
type LogBuffer struct {
*LineBuffer
// contains filtered or unexported fields
}
LogBuffer implements a fixed-size in-memory ring buffer for line-separated logs