Documentation ¶
Index ¶
- func NewMultiWriter() io.Writer
- type Colorizer
- type MultiWriter
- func (t *MultiWriter) AddWriter(name string, writer io.Writer)
- func (t *MultiWriter) Init() *MultiWriter
- func (t *MultiWriter) RemoveWriter(name string)
- func (t *MultiWriter) Write(p []byte) (n int, err error)
- func (t *MultiWriter) Writer(name string) (io.Writer, bool)
- func (t *MultiWriter) Writers() map[string]io.Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMultiWriter ¶
NewMultiWriter returns an initialized MultiWriter.
Types ¶
type Colorizer ¶
type Colorizer struct {
// contains filtered or unexported fields
}
Colorizer is a Colorizing logger middleman.
This can be used to colorize logs as they pass through to another writer. The colorization uses the UNIX-style shell color coding.
TODO: This is a very basic implementation, and could use some TLC.
Example Usage:
import ( "github.com/Masterminds/cookoo" "github.com/Masterminds/cookoo/io" // And other stuff cio "io" ) func main() { reg, router, cxt := cookoo.Cookoo() clogger := io.NewColorizer(cio.Stdout) cxt.AddLogger("stdout", clogger) // etc. }
Given the above, log messages will be colorized before written to `io.Stdout`.
func NewColorizer ¶
NewColorizer creates a new colorizer that wraps a given io.Writer.
type MultiWriter ¶
type MultiWriter struct {
// contains filtered or unexported fields
}
MultiWriter enables you to have a writer that passes on the writing to one of more Writers where the write is duplicated to each Writer. MultiWriter is similar to the multiWriter that is part of Go. The difference is this MultiWriter allows you to manager the Writers attached to it via CRUD operations. To do this you will need to mock the type. For example, mw := NewMultiWriter() mw.(*MultiWriter).AddWriter("foo", foo)
func (*MultiWriter) AddWriter ¶
func (t *MultiWriter) AddWriter(name string, writer io.Writer)
AddWriter adds an io.Writer with an associated name.
func (*MultiWriter) Init ¶
func (t *MultiWriter) Init() *MultiWriter
Init initializes the MultiWriter.
func (*MultiWriter) RemoveWriter ¶
func (t *MultiWriter) RemoveWriter(name string)
RemoveWriter removes an io.Writer given a name.
func (*MultiWriter) Write ¶
func (t *MultiWriter) Write(p []byte) (n int, err error)
Write sends the bytes to each of the attached writers to be written.