-
Notifications
You must be signed in to change notification settings - Fork 119
/
logger.go
55 lines (45 loc) · 1.1 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
package slacker
import (
"log"
"os"
)
type Logger interface {
Info(args ...interface{})
Infof(format string, args ...interface{})
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
}
type builtinLogger struct {
debugMode bool
logger *log.Logger
}
func newBuiltinLogger(debugMode bool) *builtinLogger {
return &builtinLogger{
debugMode: debugMode,
logger: log.New(os.Stdout, "", log.LstdFlags),
}
}
func (l *builtinLogger) Info(args ...interface{}) {
l.logger.Println(args...)
}
func (l *builtinLogger) Infof(format string, args ...interface{}) {
l.logger.Printf(format, args...)
}
func (l *builtinLogger) Debug(args ...interface{}) {
if l.debugMode {
l.logger.Println(args...)
}
}
func (l *builtinLogger) Debugf(format string, args ...interface{}) {
if l.debugMode {
l.logger.Printf(format, args...)
}
}
func (l *builtinLogger) Error(args ...interface{}) {
l.logger.Println(args...)
}
func (l *builtinLogger) Errorf(format string, args ...interface{}) {
l.logger.Printf(format, args...)
}