buildlog

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package buildlog implements a pub/sub log that can have multiple readers and multiple writers.

Index

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

func (l *BuildLog) BufferedLogReader() (io.Reader, error)

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

func (l *BuildLog) Close() error

Close the log, allowing subscribers to complete. It is an error to write to the log after closing it.

func (*BuildLog) MakeWriter

func (l *BuildLog) MakeWriter(tag string) *Writer

MakeWriter creates a new log Writer that implments io.Writer and adds lines to the log each time it sees a "\n".

func (*BuildLog) NewSink

func (l *BuildLog) NewSink(name string) *LogSink

NewSink creates a new sink and attach it to the BuildLog.

func (*BuildLog) PublishEntry

func (l *BuildLog) PublishEntry(entry *common.LogEntry)

PublishEntry publishes a log entry to the sinks.

func (*BuildLog) SetupPrint

func (l *BuildLog) SetupPrint() error

SetupPrint starts a LogSink that print to sdout.

func (*BuildLog) WriteMainEntry

func (l *BuildLog) WriteMainEntry(msg string)

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.

func (*LogSink) Run

func (s *LogSink) Run()

Run consumes the log sink.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer is a struct that encapsulates a single stream writer, eg stdout / stderr.

func (*Writer) Flush

func (w *Writer) Flush()

Flush handles the scenario where the last log line doesn't have a "\n" character.

func (*Writer) Write

func (w *Writer) Write(data []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL