-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlog.go
55 lines (41 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
55
package utils
import (
"fmt"
"log"
"os"
)
var Debug = false
func LogcDebugf(format string, a ...interface{}) {
if Debug {
log.Printf(format, a...)
}
}
func LogcDebugfd(format string, a ...interface{}) {
if Debug {
file, line := logctx(1)
log.Printf("%s:%d %s", file, line, fmt.Sprintf(format, a...))
}
}
func LogcInfof(format string, a ...interface{}) {
log.Printf(format, a...)
}
func LogcInfofd(format string, a ...interface{}) {
file, line := logctx(1)
log.Printf("%s:%d %s", file, line, fmt.Sprintf(format, a...))
}
func LogcErrorf(format string, a ...interface{}) {
log.Printf("ERROR: "+format, a...)
}
func LogcErrorfd(format string, a ...interface{}) {
file, line := logctx(1)
log.Printf("ERROR: %s:%d %s", file, line, fmt.Sprintf(format, a...))
}
func LogcFatalf(format string, a ...interface{}) {
log.Printf("FATAL: "+format, a...)
os.Exit(1)
}
func LogcFatalfd(format string, a ...interface{}) {
file, line := logctx(1)
log.Printf("FATAL: %s:%d %s", file, line, fmt.Sprintf(format, a...))
os.Exit(1)
}