-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlog.go
61 lines (50 loc) · 1.23 KB
/
log.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
package gofast
import "sync/atomic"
import "github.com/bnclabs/golog"
var logok = int64(0)
// LogComponents enable logging. By default logging is disabled,
// if applications want log information for gofast components
// call this function with "self" or "all" or "gofast" as argument.
func LogComponents(components ...string) {
for _, comp := range components {
switch comp {
case "gofast", "self", "all":
atomic.StoreInt64(&logok, 1)
}
}
}
func debugf(format string, v ...interface{}) {
if atomic.LoadInt64(&logok) > 0 {
log.Debugf(format, v...)
}
}
func errorf(format string, v ...interface{}) {
if atomic.LoadInt64(&logok) > 0 {
log.Errorf(format, v...)
}
}
func fatalf(format string, v ...interface{}) {
if atomic.LoadInt64(&logok) > 0 {
log.Fatalf(format, v...)
}
}
func infof(format string, v ...interface{}) {
if atomic.LoadInt64(&logok) > 0 {
log.Infof(format, v...)
}
}
func tracef(format string, v ...interface{}) {
if atomic.LoadInt64(&logok) > 0 {
log.Tracef(format, v...)
}
}
func verbosef(format string, v ...interface{}) {
if atomic.LoadInt64(&logok) > 0 {
log.Verbosef(format, v...)
}
}
func warnf(format string, v ...interface{}) {
if atomic.LoadInt64(&logok) > 0 {
log.Warnf(format, v...)
}
}