-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlogger.go
More file actions
57 lines (46 loc) · 1.2 KB
/
logger.go
File metadata and controls
57 lines (46 loc) · 1.2 KB
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
56
57
package miio
import (
"os"
"github.com/sirupsen/logrus"
)
var (
// LOGGER implementation.
LOGGER = newLogger()
)
// ILogger defines a logger interface.
type ILogger interface {
Debug(format string, v ...interface{})
Info(format string, v ...interface{})
Warn(format string, v ...interface{})
Error(format string, v ...interface{})
Fatal(format string, v ...interface{})
}
// Default logger.
type defaultLogger struct {
}
// Creates a new default logger.
func newLogger() ILogger {
logrus.SetOutput(os.Stdout)
logrus.SetLevel(logrus.DebugLevel)
return &defaultLogger{}
}
// Debug prints debug lvl message.
func (*defaultLogger) Debug(format string, v ...interface{}) {
logrus.Debugf(format, v...)
}
// Info prints info lvl message.
func (*defaultLogger) Info(format string, v ...interface{}) {
logrus.Infof(format, v...)
}
// Warn prints warn lvl message.
func (*defaultLogger) Warn(format string, v ...interface{}) {
logrus.Warnf(format, v...)
}
// Error prints error lvl message.
func (*defaultLogger) Error(format string, v ...interface{}) {
logrus.Errorf(format, v...)
}
// Fatal prints fatal lvl message.
func (*defaultLogger) Fatal(format string, v ...interface{}) {
logrus.Fatalf(format, v...)
}