Documentation ¶
Overview ¶
Package report implements reporting support around watchable source.DataSource.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FormattedReporter ¶
type FormattedReporter interface { source.ItemWatcher Source() source.DataSource Start() error Stop() }
FormattedReporter reports observed items from a data source to a formatting function. Only works with sources that support the "text" format.
For example to send a source to stdandard output:
rep := NewPrintfReporter(someSource, fmt.Printf) if err := rep.Start(); err != nil { panic(err) } defer rep.Stop()
func NewLogfReporter ¶
func NewLogfReporter( src source.DataSource, logf func(format string, args ...interface{}), ) FormattedReporter
NewLogfReporter creates a FormattedReporter around a log formatting function. Log formatting functions are not expected to return an error, and are expected to handle their own framing concerns (e.g. adding a trailing newline).
func NewPrintfReporter ¶
func NewPrintfReporter( src source.DataSource, printf func(format string, args ...interface{}) (int, error), ) FormattedReporter
NewPrintfReporter creates a new FormattedReporter around a raw fmt.Printf-family formatting function. The formatting function is expected to return a number and error in package fmt style. NewPrintfReporter will append a newline to passed format strings, since the print formatting function is expected to not do so.