Documentation ¶
Overview ¶
Package buildlog implements a logging system for build operations. Various parts of the API use Handler's to export logging information.
Index ¶
- Variables
- func LogWriter(lh Handler, stream Stream) io.WriteCloser
- func ReadJSONStream(dst Handler, src io.Reader) error
- func ReadLog(lh Handler, stream Stream, r io.Reader) error
- func ValidateName(name string) error
- type DirLogger
- type Handler
- type IllegalRuneError
- type Line
- type LogReader
- type LogStore
- type Logger
- type Stream
Constants ¶
This section is empty.
Variables ¶
var DefaultHandler = StdLogHandler(log.New(os.Stderr, "", log.LstdFlags))
DefaultHandler is the default Handler. It logs to stderr.
var ErrInvalidStream = errors.New("invalid stream")
ErrInvalidStream is an error indicating that the stream is not valid.
Functions ¶
func LogWriter ¶
func LogWriter(lh Handler, stream Stream) io.WriteCloser
LogWriter returns an io.WriteCloser that is logged. The Handler must be mutexed if it is also used by anything else. Spawns a goroutine.
func ReadJSONStream ¶
ReadJSONStream reads a log from a JSON array.
func ReadLog ¶
ReadLog reads a log from a reader. The log is put to the Handler on the specified stream.
func ValidateName ¶
ValidateName validates a name which must only contain [a-z] or [_- ].
Types ¶
type DirLogger ¶
type DirLogger struct {
Dir string
}
DirLogger is a LogStore implementation which stores JSON logs in a directory.
type Handler ¶
Handler is an interface used for log output.
func InterceptMeta ¶
InterceptMeta returrns a Handler which executes a callback instead of logging messages in StreamMeta.
func MultiLogHandler ¶
MultiLogHandler returns a Handler that logs to all given handlers.
func MutexedLogHandler ¶
MutexedLogHandler returns a Handler which is thread-safe.
func NewJSONHandler ¶
func NewJSONHandler(w io.WriteCloser) (Handler, error)
NewJSONHandler returns a new Handler which writes a log as JSON to the given writer. If an error occured, the writer may or may not be closed.
func StdLogHandler ¶
StdLogHandler creates a Handler which wraps a go stdlib logger. For this logger, Close is a no-op.
type IllegalRuneError ¶
type IllegalRuneError struct { // Rune is the illegal rune. Rune rune // Pos is the index of the rune (by rune - not by byte). Pos int // Strign is the original string containing the invalid rune. String string }
IllegalRuneError is an error type for when an invalid rune is found.
func (IllegalRuneError) Error ¶
func (e IllegalRuneError) Error() string
type Line ¶
type Line struct { // Text is the text of the log line. Text string `json:"text"` // Stream is the stream over which the log line was recieved. Stream Stream `json:"stream"` }
Line is a line of log output.
type LogReader ¶
type LogReader interface { // ReadLog reads a log into the Handler. // The name be valid according to ValidateName. ReadLog(name string, h Handler) error }
LogReader is a generic log-reading interface.
type Logger ¶
type Logger interface { // NewLog returns a Handler to write a new log. // The name be valid according to ValidateName. NewLog(name string) (Handler, error) }
Logger is a generic logging service.
func TextLogger ¶
TextLogger returns a Logger that logs to the given io.Writer in human-readable format.
type Stream ¶
type Stream uint8
Stream is a stream which Lines can be tagged with.
func ParseStream ¶
ParseStream parses a Stream by name.