Documentation ¶
Overview ¶
Package syncbuffer provides a goroutine safe bytes.Buffer as well printing functionality to the terminal.
Package syncbuffer provides a goroutine safe bytes.Buffer as well printing functionality to the terminal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileWriter ¶
FileWriter is the interface to write to a file.
type LabeledSyncBuffer ¶
type LabeledSyncBuffer struct { *SyncBuffer // contains filtered or unexported fields }
LabeledSyncBuffer is a struct that combines a SyncBuffer with a string label.
type LabeledTermPrinter ¶
type LabeledTermPrinter struct {
// contains filtered or unexported fields
}
LabeledTermPrinter is a printer to display label and logs to the terminal.
func NewLabeledTermPrinter ¶
func NewLabeledTermPrinter(fw FileWriter, bufs []*LabeledSyncBuffer, opts ...LabeledTermPrinterOption) *LabeledTermPrinter
NewLabeledTermPrinter returns a LabeledTermPrinter that can print to the terminal filewriter from buffers.
func (*LabeledTermPrinter) IsDone ¶
func (ltp *LabeledTermPrinter) IsDone() bool
IsDone returns true if all the buffers are done.
func (*LabeledTermPrinter) Print ¶
func (ltp *LabeledTermPrinter) Print()
Print prints the label and the last N lines of logs from each buffer to the LabeledTermPrinter fileWriter and erases the previous output. If numLines is -1 then print all the values from buffers.
type LabeledTermPrinterOption ¶
type LabeledTermPrinterOption func(ltp *LabeledTermPrinter)
LabeledTermPrinterOption is a type alias to configure LabeledTermPrinter.
func WithNumLines ¶
func WithNumLines(n int) LabeledTermPrinterOption
WithNumLines sets the numlines of LabeledTermPrinter.
func WithPadding ¶
func WithPadding(n int) LabeledTermPrinterOption
WithPadding sets the padding of LabeledTermPrinter.
type SyncBuffer ¶
type SyncBuffer struct {
// contains filtered or unexported fields
}
SyncBuffer is a synchronized buffer that can be used to store output data and coordinate between multiple goroutines.
func New ¶
func New() *SyncBuffer
New creates and returns a new SyncBuffer object with an initialized 'done' channel.
func (*SyncBuffer) Copy ¶
func (buf *SyncBuffer) Copy(r io.Reader) error
Copy reads all the content of an io.Reader into a SyncBuffer and an error if copy is failed.
func (*SyncBuffer) IsDone ¶
func (b *SyncBuffer) IsDone() bool
IsDone returns true if the Done channel has been closed, otherwise return false.
func (*SyncBuffer) WithLabel ¶
func (buf *SyncBuffer) WithLabel(label string) *LabeledSyncBuffer
WithLabel creates and returns a new LabeledSyncBuffer with the given label and SyncBuffer.