package logger import ( "fmt" "io" "os" ) type Log struct { quiet bool debug bool errOut io.Writer stdOut io.Writer } func NewLogger(quiet, debug bool, stdOut, errOut io.Writer) *Log { if stdOut == nil { stdOut = os.Stdout } if errOut == nil { errOut = os.Stderr } return &Log{ quiet: quiet, debug: debug, stdOut: stdOut, errOut: errOut, } } func (l *Log) Error(s ...interface{}) { fmt.Fprint(l.errOut, s...) } func (l *Log) Errorf(f string, s ...interface{}) { fmt.Fprint(l.errOut, s...) } func (l *Log) Log(s ...interface{}) { if !l.quiet { fmt.Fprint(l.stdOut, s...) } } func (l *Log) Logf(f string, s ...interface{}) { if !l.quiet { fmt.Fprintf(l.stdOut, f, s...) } } func (l *Log) Debug(s ...interface{}) { if l.debug { fmt.Fprint(l.errOut, s...) } } func (l *Log) Debugf(f string, s ...interface{}) { if l.debug { fmt.Fprintf(l.errOut, f, s...) } }