-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
42 lines (34 loc) · 1022 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
package godeconz
import (
"log"
"os"
)
// Logger supports trace for maximal information, debug for general debug information and error in case of an error.
type Logger interface {
Errorf(format string, v ...interface{})
Infof(format string, v ...interface{})
Warnf(format string, v ...interface{})
Debugf(format string, v ...interface{})
}
type BuiltinLogger struct {
logger *log.Logger
}
func NewBuiltinLogger() *BuiltinLogger {
return &BuiltinLogger{logger: log.New(os.Stdout, "", 5)}
}
func (l BuiltinLogger) Debugf(format string, args ...interface{}) {
l.logger.Print("[Debug]")
l.logger.Printf(format, args...)
}
func (l BuiltinLogger) Errorf(format string, args ...interface{}) {
l.logger.Print("[Error]")
l.logger.Printf(format, args...)
}
func (l BuiltinLogger) Warnf(format string, args ...interface{}) {
l.logger.Print("[Warn]")
l.logger.Printf(format, args...)
}
func (l BuiltinLogger) Infof(format string, args ...interface{}) {
l.logger.Print("[Info]")
l.logger.Printf(format, args)
}