blob: 6cd44c7a5d79030b0c739d10b25919f866b3b531 [file] [log] [blame]
Matthias Andreas Benkard832a54e2019-01-29 09:27:38 +01001package log
2
3import (
4 stdlog "log"
5 "os"
6)
7
8// StdLogger corresponds to a minimal subset of the interface satisfied by stdlib log.Logger
9type StdLogger interface {
10 Print(v ...interface{})
11 Printf(format string, v ...interface{})
12}
13
14var Logger StdLogger
15
16func init() {
17 // default Logger
18 SetLogger(stdlog.New(os.Stderr, "[restful] ", stdlog.LstdFlags|stdlog.Lshortfile))
19}
20
21// SetLogger sets the logger for this package
22func SetLogger(customLogger StdLogger) {
23 Logger = customLogger
24}
25
26// Print delegates to the Logger
27func Print(v ...interface{}) {
28 Logger.Print(v...)
29}
30
31// Printf delegates to the Logger
32func Printf(format string, v ...interface{}) {
33 Logger.Printf(format, v...)
34}