added Writers func

This commit is contained in:
Stephen Searles
2015-11-21 13:51:16 -08:00
parent e177a9b22a
commit 5092da6721
+19 -7
View File
@@ -117,21 +117,33 @@ type Interface interface {
// write to w.
func Writer(w io.Writer, debug, info string) Interface {
return writerInterface{
debug: debug,
info: info,
w: w,
debug: debug,
info: info,
wDebug: w,
wInfo: w,
}
}
// Writers returns an Interface with the given debug and info prefixes that
// write to wDebug and wInfo respectively.
func Writers(wDebug, wInfo io.Writer, debug, info string) Interface {
return writerInterface{
debug: debug,
info: info,
wDebug: wDebug,
wInfo: wInfo,
}
}
type writerInterface struct {
debug, info string
w io.Writer
debug, info string
wDebug, wInfo io.Writer
}
func (w writerInterface) Print(v string) {
fmt.Fprint(w.w, w.info, v)
fmt.Fprint(w.wInfo, w.info, v)
}
func (w writerInterface) Debug(v string) {
fmt.Fprint(w.w, w.debug, v)
fmt.Fprint(w.wDebug, w.debug, v)
}