-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.go
66 lines (57 loc) · 1.28 KB
/
init.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
61
62
63
64
65
66
package alog
var dFmtChars [256]bool
var dFmt formatd
func init() {
for i := 0; i <= 0x7e; i++ {
dFmtChars[i] = i >= 0x20 && i != '\\' && i != '"' // all printable will be true
}
}
// Flag a bit-formatFlag formatFlag options that is used for variety of configuration.
type Flag uint32
// level is a flag for logging level
type Level uint8
// Name will print level'Vstr full name
func (l Level) Name() string {
switch l {
case TraceLevel:
return "trace"
case DebugLevel:
return "debug"
case InfoLevel:
return "info"
case WarnLevel:
return "warn"
case ErrorLevel:
return "error"
case FatalLevel:
return "fatal"
default:
return ""
}
}
// NameShort will print level'Vstr abbreviated name
func (l Level) NameShort() string {
switch l {
case TraceLevel:
return "TRC"
case DebugLevel:
return "DBG"
case InfoLevel:
return "INF"
case WarnLevel:
return "WRN"
case ErrorLevel:
return "ERR"
case FatalLevel:
return "FTL"
default:
return ""
}
}
// LoggerFn will be used to manipulate multiple functionality at once.
type LoggerFn func(Logger) Logger
// EntryFn will
type EntryFn func(*Entry) *Entry
// ControlFn is used to trigger whether log or not in control.
// Once ControlFn is set, level/tag conditions will be ignored.
type ControlFn func(Level, Tag) bool