-
Notifications
You must be signed in to change notification settings - Fork 15
/
log.go
38 lines (30 loc) · 875 Bytes
/
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
package watchdog
import "log"
// logger is an interface to be implemented by custom loggers.
type logger interface {
Debugf(template string, args ...interface{})
Infof(template string, args ...interface{})
Warnf(template string, args ...interface{})
Errorf(template string, args ...interface{})
}
var _ logger = (*stdlog)(nil)
// stdlog is a logger that proxies to a standard log.logger.
type stdlog struct {
log *log.Logger
debug bool
}
func (s *stdlog) Debugf(template string, args ...interface{}) {
if !s.debug {
return
}
s.log.Printf(template, args...)
}
func (s *stdlog) Infof(template string, args ...interface{}) {
s.log.Printf(template, args...)
}
func (s *stdlog) Warnf(template string, args ...interface{}) {
s.log.Printf(template, args...)
}
func (s *stdlog) Errorf(template string, args ...interface{}) {
s.log.Printf(template, args...)
}