-
Notifications
You must be signed in to change notification settings - Fork 10
/
log.go
48 lines (40 loc) · 1.09 KB
/
log.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
package bring
import "log"
// Logger interface used by this package. It is compatible with Logrus,
// but anything implementing this interface can be used
type Logger interface {
Tracef(format string, args ...interface{})
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Errorf(format string, args ...interface{})
}
// Simple console logger
type DefaultLogger struct {
Quiet bool
}
func (l *DefaultLogger) Tracef(format string, args ...interface{}) {
if !l.Quiet {
log.Printf("TRAC: "+format, args...)
}
}
func (l *DefaultLogger) Debugf(format string, args ...interface{}) {
if !l.Quiet {
log.Printf("DEBU: "+format, args...)
}
}
func (l *DefaultLogger) Infof(format string, args ...interface{}) {
if !l.Quiet {
log.Printf("INFO: "+format, args...)
}
}
func (l *DefaultLogger) Warnf(format string, args ...interface{}) {
if !l.Quiet {
log.Printf("WARN: "+format, args...)
}
}
func (l *DefaultLogger) Errorf(format string, args ...interface{}) {
if !l.Quiet {
log.Printf("ERRO: "+format, args...)
}
}