-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.go
55 lines (39 loc) · 758 Bytes
/
debug.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 skiplistmap
import (
"fmt"
"io"
)
type statKey byte
var EnableStats bool = false
var DebugStats map[statKey]int = map[statKey]int{}
func ResetStats() {
DebugStats = map[statKey]int{}
}
type LogLevel byte
const (
LogDebug LogLevel = iota
LogInfo
LogWarn
LogError
LogFatal
)
//const CurrentLogLevel LogLevel = LogDebug
const CurrentLogLevel LogLevel = LogInfo
var logio io.Writer = io.Discard
func SetLogIO(w io.Writer) {
logio = w
}
func Log(l LogLevel, s string, args ...interface{}) {
if l == LogFatal {
panic(fmt.Sprintf(s, args...))
}
if CurrentLogLevel >= l {
fmt.Fprintf(logio, s, args...)
}
}
func IsDebug() bool {
return CurrentLogLevel == LogDebug
}
func IsInfo() bool {
return CurrentLogLevel <= LogInfo
}