Documentation
¶
Overview ¶
Package buildlog implements a pub/sub log that can have multiple readers and multiple writers.
Index ¶
- type BuildLog
- func (l *BuildLog) BufferedLogReader() (io.Reader, error)
- func (l *BuildLog) Close() error
- func (l *BuildLog) MakeWriter(tag string) *Writer
- func (l *BuildLog) NewSink(name string) *LogSink
- func (l *BuildLog) PublishEntry(entry *common.LogEntry)
- func (l *BuildLog) SetupPrint() error
- func (l *BuildLog) WriteMainEntry(msg string)
- type LogSink
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildLog ¶
type BuildLog struct { BufferMu sync.Mutex // protect StructuredEntryBuffer, BufferPath, EntryBufferErr StructuredEntryBuffer io.WriteCloser BufferPath string EntryBufferErr error // contains filtered or unexported fields }
A BuildLog captures the stdout/stderr data for a build. Effectively, it functions as a pub/sub topic with multiple publishers and multiple subscribers.
func (*BuildLog) BufferedLogReader ¶
BufferedLogReader returns a reader that can be fed to an HTTP request for logs. This method should only be called after the log is closed and all entries have been finished, otherwise access to l.entryBuffer can create a data race.
func (*BuildLog) Close ¶
Close the log, allowing subscribers to complete. It is an error to write to the log after closing it.
func (*BuildLog) MakeWriter ¶
MakeWriter creates a new log Writer that implments io.Writer and adds lines to the log each time it sees a "\n".
func (*BuildLog) PublishEntry ¶
PublishEntry publishes a log entry to the sinks.
func (*BuildLog) SetupPrint ¶
SetupPrint starts a LogSink that print to sdout.
func (*BuildLog) WriteMainEntry ¶
WriteMainEntry is a helper to write an entry under the "MAIN" tag.
type LogSink ¶
type LogSink struct { Name string Lines chan *common.LogEntry // We wait on a single message to the `result` channel after flushing all lines to the sink. Result chan error HandleBatch func([]*common.LogEntry) error }
LogSink is a struct that encapsulates a log sink.