1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
package logger
import (
"fmt"
"io"
)
// Writer provides a logger that outputs logging to the given writer.
func Writer(w io.Writer) Logger {
return writer{Writer: w}
}
type writer struct {
io.Writer
}
func (w writer) Debugf(format string, args ...interface{}) {
fmt.Fprintf(w.Writer, "[DEBUG] "+format+"\n", args...)
}
func (w writer) Infof(format string, args ...interface{}) {
fmt.Fprintf(w.Writer, "[INFO] "+format+"\n", args...)
}
func (w writer) Warnf(format string, args ...interface{}) {
fmt.Fprintf(w.Writer, "[WARN] "+format+"\n", args...)
}
func (w writer) Errorf(format string, args ...interface{}) {
fmt.Fprintf(w.Writer, "[ERROR] "+format+"\n", args...)
}
|