Documentation ¶
Overview ¶
Package logstreamer provides a mechanism to allow multiple observers to observer log output when backpressure is not acceptable.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StreamToWriter ¶
func StreamToWriter(stream *BufferedLogStream, w io.Writer, addTimestamps bool) (err error)
StreamToWriter creates a new observer for a provided stream, and writes the results to the provided writer. If skipped entries are detected, a message is written to the writer indicating so.
Types ¶
type BufferedLogStream ¶
type BufferedLogStream struct {
// contains filtered or unexported fields
}
BufferedLogStream is a buffered stream of logs. It allows observers to view X amount of entries in the past upon creation.
func NewBufferedLogStream ¶
func NewBufferedLogStream(maxEntries int) *BufferedLogStream
NewBufferedLogStream creates a new BufferedLogStream, with maxEntries as the buffer size.
func (*BufferedLogStream) NewObserver ¶
func (b *BufferedLogStream) NewObserver() StreamObserver
NewObserver creates a new StreamObserver, pre-populated with whatever is currently in the buffer. Callers should call Close() when finished.
func (*BufferedLogStream) WriteLine ¶
func (b *BufferedLogStream) WriteLine(line string) error
WriteLine writes a line to the stream. The line is timestamped based on insertion time, not observed time.
type LogEntry ¶
LogEntry represents a log entry. The log number indicates the log number since the start of the stream. If an observer observes a gap in log numbers, then they have lost log entries. This is caused by the observer not being able to process logs as fast as they're being generated.
type StreamObserver ¶
type StreamObserver struct {
// contains filtered or unexported fields
}
StreamObserver is an observer to a stream. Log entries are sent through the streams channel. Users of StreamObserver should call Close() when finished with the observer.
func (*StreamObserver) Chan ¶
func (s *StreamObserver) Chan() <-chan LogEntry
Chan returns a receive-only channel of LogEntries.
func (*StreamObserver) Close ¶
func (s *StreamObserver) Close() error
Close closes the stream observer, freeing any resources required by the associated stream.