-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.go
38 lines (30 loc) · 831 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
package bdodb
import (
"log"
"os"
)
// Logger interface
type Logger interface {
Errorf(f string, v ...interface{})
Warningf(f string, v ...interface{})
Infof(f string, v ...interface{})
Debugf(f string, v ...interface{})
}
type defaultLog struct {
*log.Logger
}
func (l *defaultLog) Errorf(f string, v ...interface{}) {
l.Printf("ERROR: "+f, v...)
}
func (l *defaultLog) Warningf(f string, v ...interface{}) {
l.Printf("WARNING: "+f, v...)
}
func (l *defaultLog) Infof(f string, v ...interface{}) {
l.Printf("INFO: "+f, v...)
}
func (l *defaultLog) Debugf(f string, v ...interface{}) {
l.Printf("DEBUG: "+f, v...)
}
// DefaultLogger is the default logger for bdodb
// Set different logger to modify the logging behavior
var DefaultLogger Logger = &defaultLog{Logger: log.New(os.Stderr, "bdodb ", log.LstdFlags)}