2017-02-07 21:33:23 +00:00
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
|
|
|
stdlog "log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Logger corresponds to a minimal subset of the interface satisfied by stdlib log.Logger
|
|
|
|
type StdLogger interface {
|
|
|
|
Print(v ...interface{})
|
|
|
|
Printf(format string, v ...interface{})
|
|
|
|
}
|
|
|
|
|
|
|
|
var Logger StdLogger
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
// default Logger
|
2017-06-11 16:03:28 +00:00
|
|
|
SetLogger(stdlog.New(os.Stderr, "[restful] ", stdlog.LstdFlags|stdlog.Lshortfile))
|
2017-02-07 21:33:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func SetLogger(customLogger StdLogger) {
|
|
|
|
Logger = customLogger
|
|
|
|
}
|
|
|
|
|
|
|
|
func Print(v ...interface{}) {
|
|
|
|
Logger.Print(v...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Printf(format string, v ...interface{}) {
|
|
|
|
Logger.Printf(format, v...)
|
|
|
|
}
|