-
Notifications
You must be signed in to change notification settings - Fork 11
/
log.go
68 lines (54 loc) · 994 Bytes
/
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
62
63
64
65
66
67
68
package logger
import (
"fmt"
"log"
)
const (
ERROR = 1
INFO = 2
VERBOSE = 3
DEBUG = 7
)
var (
level = DEBUG
)
func SetLevel(l int) {
level = l
}
func Errorf(format string, v ...interface{}) {
printfAtLevel(ERROR, format, v...)
}
func Error(v ...interface{}) {
printAtLevel(ERROR, v...)
}
func Infof(format string, v ...interface{}) {
printfAtLevel(INFO, format, v...)
}
func Info(v ...interface{}) {
printAtLevel(INFO, v...)
}
func Verbosef(format string, v ...interface{}) {
printfAtLevel(VERBOSE, format, v...)
}
func Verbose(v ...interface{}) {
printAtLevel(VERBOSE, v...)
}
func Debugf(format string, v ...interface{}) {
printfAtLevel(DEBUG, format, v...)
}
func Debug(v ...interface{}) {
printAtLevel(DEBUG, v...)
}
func printfAtLevel(l int, format string, v ...interface{}) {
if level < l {
return
}
out := fmt.Sprintf(format, v...)
log.Print(out)
}
func printAtLevel(l int, v ...interface{}) {
if level < l {
return
}
log.Println(v...)
}