-
Notifications
You must be signed in to change notification settings - Fork 1
/
log_internal.go
60 lines (50 loc) · 963 Bytes
/
log_internal.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
package log
import (
"sync"
)
var internal = struct {
level struct {
normal struct {
file Level
console Level
}
dyeing struct {
file Level
console Level
}
}
file struct {
name *string
size int64
lock sync.Mutex // TODO: 以后再用更高性能的方案代替, 暂时先实现功能
logs []*logItem
}
caller struct {
skip int
}
levelToString []string
debugf func(f string, a ...any)
}{}
func internalGetCallerSkip() int {
return internal.caller.skip + 3
}
func init() {
internal.level.normal.file = NoLog
internal.level.normal.console = InfoLevel
internal.level.dyeing.file = NoLog
internal.level.dyeing.console = InfoLevel
internal.levelToString = []string{
"TRACE",
"DEBUG",
"INFO",
"WARN",
"ERROR",
"FATAL",
"",
}
log := "./log.log"
internal.file.size = 500 * 1000 * 1000 // 500 MB
internal.file.name = &log
go fileLogRoutine()
internal.debugf = func(string, ...any) {}
}