added Writers func

master
Stephen Searles 9 years ago
parent e177a9b22a
commit 5092da6721
  1. 26
      log.go

@ -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)
}

Loading…
Cancel
Save