-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.go
64 lines (54 loc) · 1.38 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
package franky
import (
"fmt"
)
// Logger is a basic interface for use in many projects
type Logger interface {
Printf(string, ...interface{})
Infof(string, ...interface{})
Errorf(string, ...interface{})
Debugf(string, ...interface{})
}
type noopLogger struct{}
// NoopLogger implements the logger interface
// but will not do anything
var NoopLogger = &noopLogger{}
func (l *noopLogger) Printf(string, ...interface{}) {}
func (l *noopLogger) Infof(string, ...interface{}) {}
func (l *noopLogger) Errorf(string, ...interface{}) {}
func (l *noopLogger) Debugf(string, ...interface{}) {}
func (l *noopLogger) Warnf(string, ...interface{}) {}
type defaultLogger struct{}
// DefaultLogger is a default way of interacting with
// logging system
var DefaultLogger = &defaultLogger{}
func (l *defaultLogger) Printf(s string, args ...interface{}) {
fmt.Printf(
fmt.Sprintf("%s\n", s),
args...,
)
}
func (l *defaultLogger) Infof(s string, args ...interface{}) {
fmt.Printf(
fmt.Sprintf("[INFO] %s\n", s),
args...,
)
}
func (l *defaultLogger) Errorf(s string, args ...interface{}) {
fmt.Printf(
fmt.Sprintf("[ERROR] %s\n", s),
args...,
)
}
func (l *defaultLogger) Debugf(s string, args ...interface{}) {
fmt.Printf(
fmt.Sprintf("[DEBUG] %s\n", s),
args...,
)
}
func (l *defaultLogger) Warnf(s string, args ...interface{}) {
fmt.Printf(
fmt.Sprintf("[WARN] %s\n", s),
args...,
)
}