-
Notifications
You must be signed in to change notification settings - Fork 1
/
log.go
54 lines (45 loc) · 1.03 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
package main
import (
"fmt"
"os"
)
func LogI(tag string, args ...interface{}) {
LogLevel("I", tag, args...)
}
func LogD(tag string, args ...interface{}) {
LogLevel("D", tag, args...)
}
func LogW(tag string, args ...interface{}) {
LogLevel("W", tag, args...)
}
func LogE(tag string, args ...interface{}) {
LogLevel("E", tag, args...)
}
func LogF(tag string, args ...interface{}) {
LogLevel("E", tag, args...)
os.Exit(1)
}
func LogV(tag string, args ...interface{}) {
LogLevel("V", tag, args...)
}
func LogLevel(level string, tag string, args ...interface{}) {
extra := make([]interface{}, 0)
switch level {
case "I":
extra = append(extra, "\u001b[34m["+tag+"]")
case "D":
extra = append(extra, "\u001b[35m["+tag+"]")
case "W":
extra = append(extra, "\u001b[33m["+tag+"]")
case "E":
extra = append(extra, "\u001b[31m["+tag+"]")
case "V":
extra = append(extra, "["+tag+"]")
}
extra = append(extra, args...)
extra = append(extra, "\u001b[0m")
Log(extra...)
}
func Log(args ...interface{}) {
fmt.Println(args...)
}