-
Notifications
You must be signed in to change notification settings - Fork 1
/
logging.go
54 lines (44 loc) · 1.41 KB
/
logging.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
49
50
51
52
53
54
package logging
import (
log "github.com/sirupsen/logrus"
)
//Logger interface that allows abstracting away the concrete logger implementation we are using
type Logger interface {
//Fatal causes the application to terminate with the given error message
Fatal(args ...interface{})
//Fatalf causes the application to terminate with the given error message
Fatalf(format string, args ...interface{})
//Error logs a message at ERROR level on the default logger
Error(args ...interface{})
//Errorf logs a message at ERROR level on the default logger
Errorf(format string, args ...interface{})
//Info logs a message at INFO level on the default logger
Info(args ...interface{})
//Infof logs a message at INFO level on the default logger
Infof(format string, args ...interface{})
}
//NewLogger instantiates a new logger and returns it
func NewLogger() Logger {
log.SetFormatter(&log.JSONFormatter{})
return &logger{}
}
type logger struct {
}
func (l *logger) Error(args ...interface{}) {
log.Error(args...)
}
func (l *logger) Errorf(format string, args ...interface{}) {
log.Errorf(format, args...)
}
func (l *logger) Fatal(args ...interface{}) {
log.Fatal(args...)
}
func (l *logger) Fatalf(format string, args ...interface{}) {
log.Fatalf(format, args...)
}
func (l *logger) Info(args ...interface{}) {
log.Info(args...)
}
func (l *logger) Infof(format string, args ...interface{}) {
log.Infof(format, args...)
}