-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlogger.go
85 lines (65 loc) · 2.14 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package curlyq
import (
"log"
)
// Logger exposes an interface for a leveled logger.
// You can provide a Logger to a Consumer and a Producer
// to modify CurlyQ's default logging behavior.
type Logger interface {
// Debug logs fine-grained information,
// such as when a given process starts and ends.
Debug(...interface{})
// Info logs useful information,
// such as which job is currently being processed.
Info(...interface{})
// Warn logs non-critical errors,
// such as network issues that are treated as transient errors.
Warn(...interface{})
// Error logs critical errors,
// such as redis issues which might affect the consistency of the queue.
Error(...interface{})
}
// DefaultLogger is a Logger that send all non-debug logs to stdout.
type DefaultLogger struct{}
// Debug does nothing.
func (l *DefaultLogger) Debug(args ...interface{}) {}
// Info logs info level information to stdout.
func (l *DefaultLogger) Info(args ...interface{}) {
log.Println(args...)
}
// Warn logs warn level information to stdout.
func (l *DefaultLogger) Warn(args ...interface{}) {
log.Println(args...)
}
// Error logs error level information to stdout.
func (l *DefaultLogger) Error(args ...interface{}) {
log.Println(args...)
}
// EmptyLogger is a Logger that logs nothing.
type EmptyLogger struct{}
// Debug does nothing.
func (l *EmptyLogger) Debug(args ...interface{}) {}
// Info does nothing.
func (l *EmptyLogger) Info(args ...interface{}) {}
// Warn does nothing.
func (l *EmptyLogger) Warn(args ...interface{}) {}
// Error does nothing.
func (l *EmptyLogger) Error(args ...interface{}) {}
// LoudLogger is a Logger that sends all logs to stdout.
type LoudLogger struct{}
// Debug logs debug level information to stdout.
func (l *LoudLogger) Debug(args ...interface{}) {
log.Println(args...)
}
// Info logs info level information to stdout.
func (l *LoudLogger) Info(args ...interface{}) {
log.Println(args...)
}
// Warn logs warn level information to stdout.
func (l *LoudLogger) Warn(args ...interface{}) {
log.Println(args...)
}
// Error logs error level information to stdout.
func (l *LoudLogger) Error(args ...interface{}) {
log.Println(args...)
}