Documentation ¶
Index ¶
- type HookFunc
- type LineWriter
- func (w *LineWriter) Close() error
- func (w *LineWriter) WithAfterLine(f HookFunc) *LineWriter
- func (w *LineWriter) WithBeforeLine(f HookFunc) *LineWriter
- func (w *LineWriter) WithPrefix(p []byte) *LineWriter
- func (w *LineWriter) WithPrefixString(p string) *LineWriter
- func (w *LineWriter) WithSuffix(s []byte) *LineWriter
- func (w *LineWriter) WithSuffixString(s string) *LineWriter
- func (w *LineWriter) Write(data []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HookFunc ¶
HookFunc is a type definition for a hook calls that LineWriter does at certain moments of operation. Examples are: before writing a line to the underlying writer or after writing a new line. HookFunc receives an underlying writer as an argument.
type LineWriter ¶
type LineWriter struct {
// contains filtered or unexported fields
}
LineWriter is a wrapper around io.Writer with main use case to have something done before or after writing a line to the underlying writer (for example, adding a prefix or a suffix).
func NewLineWriter ¶
func NewLineWriter(writer io.Writer) *LineWriter
NewLineWriter creates a new LineWriter. A single argument is a underlying writer.
func (*LineWriter) Close ¶
func (w *LineWriter) Close() error
Close flushes what's left in the buffer to the w.writer and calls before line hook if it's set.
func (*LineWriter) WithAfterLine ¶
func (w *LineWriter) WithAfterLine(f HookFunc) *LineWriter
WithAfterLine is a builder method that sets a hook to run every time after a line is written to the writer.
func (*LineWriter) WithBeforeLine ¶
func (w *LineWriter) WithBeforeLine(f HookFunc) *LineWriter
WithBeforeLine is a builder method that sets a hook to run every time before a line is written to the writer.
func (*LineWriter) WithPrefix ¶
func (w *LineWriter) WithPrefix(p []byte) *LineWriter
WithPrefix is a builder method that sets a hook that adds a prefix to each written line.
func (*LineWriter) WithPrefixString ¶
func (w *LineWriter) WithPrefixString(p string) *LineWriter
WithPrefixString is a convenience method for WithPrefix that receives a string argument.
func (*LineWriter) WithSuffix ¶
func (w *LineWriter) WithSuffix(s []byte) *LineWriter
WithSuffix is a builder method that sets a hook that adds a suffix to each written line.
func (*LineWriter) WithSuffixString ¶
func (w *LineWriter) WithSuffixString(s string) *LineWriter
WithSuffixString is a convenience method for WithSuffix that receives a string argument.