-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobals.go
111 lines (96 loc) · 2.48 KB
/
globals.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package logg
import (
"os"
)
// Global Logg configuration
var logg = New(os.Stderr)
// Default parameters
const (
DefaultFormat = Pretty
DefaultColorOutput = true
DefaultFlags = LstdFlags
DefaultMinimumLevel = Info
ContextCallDepth = 4
escape = "\x1b"
escapeClose = "\x1b[0m"
digits01 = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
digits10 = "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
)
// These flags define which text to prefix to each log entry generated by the Logger.
// Bits are or'ed together to control what's printed.
// There is no control over the order they appear (the order listed
// here) or the format they present (as described in the comments).
// The prefix is followed by a colon only when Llongfile or Lshortfile
// is specified.
// For example, flags Ldate | Ltime (or LstdFlags) produce,
// 2009/01/23 01:23:23 message
// while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,
// 2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message
const (
Ldate = 1 << iota // the date in the local time zone: 2009/01/23
Ltime // the time in the local time zone: 01:23:23
Lmicroseconds // microsecond resolution: 01:23:23.123123. assumes Ltime.
Llongfile // full file name and line number: /a/b/c/d.go:23
Lshortfile // final file name element and line number: d.go:23. overrides Llongfile
LUTC // if Ldate or Ltime is set, use UTC rather than the local time zone
LstdFlags = Ldate | Ltime // initial values for the standard logger
)
// Base types
type (
format int
level int
)
var (
levels = []string{"DBG", "INF", "ERR", "WRN", "PNC", "DEBUG", "INFO", "ERROR", "WARN", "PANIC"}
colors = [][]byte{generate(HiCyan), generate(HiYellow), generate(Red), generate(HiGreen), generate(Red)}
timeColor = generate(7)
)
// Output formats
const (
Pretty format = iota
Json
)
// Log levels.
const (
Debug level = iota
Info
Error
Warning
Panic
Empty level = -1
)
// Base colors for console
const (
Black int = iota
Red
Green
Yellow
Blue
Magenta
Cyan
White
)
// High intensity colors
const (
HiBlack int = iota + 60
HiRed
HiGreen
HiYellow
HiBlue
HiMagenta
HiCyan
HiWhite
)
// Base attributes
const (
Reset int = iota
Bold
Faint
Italic
Underline
BlinkSlow
BlinkRapid
ReverseVideo
Concealed
CrossedOut
)