forked from digisan/logkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
var.go
58 lines (49 loc) · 1.13 KB
/
var.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
package logkit
import (
"fmt"
"os"
"strings"
"time"
. "github.com/digisan/gotk/print"
)
var (
fPt = fmt.Print
fSf = fmt.Sprintf
fEf = fmt.Errorf
sHasSuffix = strings.HasSuffix
)
const (
tmFmt = "2006/01/02 15:04:05 " // end with " " same as log.Printf
logfile4test = "./a/b.log"
LF = "\n\t\t\t\t"
longLF = "\n\t\t\t\t\t\t"
)
type logCategory int
const (
FILE logCategory = 0
INFO logCategory = 1
DEBUG logCategory = 2
WARN logCategory = 3
FAIL logCategory = 4
)
var (
mLvlDesc map[logCategory]string = map[logCategory]string{
FILE: "",
INFO: "INFO",
DEBUG: "DEBUG",
WARN: "WARN",
FAIL: "FAIL",
}
mLvlClr map[logCategory]func(a ...any) string = map[logCategory]func(a ...any) string{
FILE: func(a ...any) string { return fmt.Sprint(a...) },
INFO: G, // W
DEBUG: B,
WARN: Y,
FAIL: R,
}
log2C = true
log2F = false
warnDetail = true
mPathFile map[string]*os.File = make(map[string]*os.File)
nowStr = func() string { return time.Now().Format(tmFmt) }
)