forked from Netflix/spectator-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
44 lines (35 loc) · 830 Bytes
/
logger.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
package spectator
import (
"log"
"os"
)
type Logger interface {
Debugf(format string, v ...interface{})
Infof(format string, v ...interface{})
Errorf(format string, v ...interface{})
}
type DefaultLogger struct {
debug *log.Logger
info *log.Logger
error *log.Logger
}
func defaultLogger() *DefaultLogger {
flags := log.LstdFlags
debug := log.New(os.Stdout, "DEBUG: ", flags)
info := log.New(os.Stdout, "INFO: ", flags)
err := log.New(os.Stdout, "ERROR: ", flags)
return &DefaultLogger{
debug,
info,
err,
}
}
func (l *DefaultLogger) Debugf(format string, v ...interface{}) {
l.debug.Printf(format, v...)
}
func (l *DefaultLogger) Infof(format string, v ...interface{}) {
l.info.Printf(format, v...)
}
func (l *DefaultLogger) Errorf(format string, v ...interface{}) {
l.error.Printf(format, v...)
}