-
Notifications
You must be signed in to change notification settings - Fork 129
/
logger.go
67 lines (51 loc) · 1.86 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package rabbitmq
import (
"fmt"
"log"
"os"
"github.com/wagslane/go-rabbitmq/internal/logger"
)
// Logger is describes a logging structure. It can be set using
// WithPublisherOptionsLogger() or WithConsumerOptionsLogger().
type Logger logger.Logger
const loggingPrefix = "gorabbit"
type stdDebugLogger struct{}
// Fatalf -
func (l stdDebugLogger) Fatalf(format string, v ...interface{}) {
log.Fatalf(fmt.Sprintf("%s FATAL: %s", loggingPrefix, format), v...)
}
// Errorf -
func (l stdDebugLogger) Errorf(format string, v ...interface{}) {
log.Printf(fmt.Sprintf("%s ERROR: %s", loggingPrefix, format), v...)
}
// Warnf -
func (l stdDebugLogger) Warnf(format string, v ...interface{}) {
log.Printf(fmt.Sprintf("%s WARN: %s", loggingPrefix, format), v...)
}
// Infof -
func (l stdDebugLogger) Infof(format string, v ...interface{}) {
log.Printf(fmt.Sprintf("%s INFO: %s", loggingPrefix, format), v...)
}
// Debugf -
func (l stdDebugLogger) Debugf(format string, v ...interface{}) {
log.Printf(fmt.Sprintf("%s DEBUG: %s", loggingPrefix, format), v...)
}
// simpleLogF is used to support logging in the test functions.
// This could be exposed publicly for integration in more simple logging interfaces.
type simpleLogF func(string, ...interface{})
func (l simpleLogF) Fatalf(format string, v ...interface{}) {
l(fmt.Sprintf("%s FATAL: %s", loggingPrefix, format), v...)
os.Exit(1)
}
func (l simpleLogF) Errorf(format string, v ...interface{}) {
l(fmt.Sprintf("%s ERROR: %s", loggingPrefix, format), v...)
}
func (l simpleLogF) Warnf(format string, v ...interface{}) {
l(fmt.Sprintf("%s WARN: %s", loggingPrefix, format), v...)
}
func (l simpleLogF) Infof(format string, v ...interface{}) {
l(fmt.Sprintf("%s INFO: %s", loggingPrefix, format), v...)
}
func (l simpleLogF) Debugf(format string, v ...interface{}) {
l(fmt.Sprintf("%s DEBUG: %s", loggingPrefix, format), v...)
}