-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
152 lines (145 loc) · 4.22 KB
/
config.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package glog
import "time"
type Config struct {
TablePadChar rune
AutoFloatPrecision int
TimeFormat,
TimeFormat12hr,
DateFormat,
DateTimeFormat,
DateTimeFormat12hr string
ColorURLSeparators,
ColorPathSeparator,
ColorPath,
ColorScheme,
ColorUser,
ColorPassword,
ColorURLPath,
ColorQueryKey,
ColorQueryValue,
ColorFragment,
ColorNil,
ColorIntNegative,
ColorIntZero,
ColorIntPositive,
ColorUintZero,
ColorUintPositive,
ColorFloatNegative,
ColorFloatZero,
ColorFloatPositive,
ColorPercentageNegative,
ColorPercentageZero,
ColorPercentagePositive,
ColorBoolFalse,
ColorBoolTrue,
ColorTime,
ColorDuration,
ColorReason,
ColorFile,
ColorError,
ColorUnitHumanReadable,
ColorIndicator,
ColorIndicatorInfo,
ColorIndicatorOK,
ColorIndicatorSuccess,
ColorIndicatorNotOK,
ColorIndicatorError,
ColorIndicatorWarning,
ColorIndicatorDebug,
ColorIndicatorTrace,
ColorIndicatorProgress,
ColorIndicatorQuestion int
ColorsDisabled,
ShowRuntimeSeconds,
ShowRuntimeMilliseconds,
ShowDateTime,
ShowSubsystem,
ShowIndicator,
SplitOnNewLine,
CheckIfURLIsAlive bool
ProgressBarWidth int
Indicators map[rune]*Indicator
reverseDNSCache map[string]string
createdAt time.Time
}
func (c *Config) AddIndicator(indicator rune, value string, color int) {
c.Indicators[indicator] = NewIndicator(value, color)
}
func NewDefaultConfig() *Config {
c := &Config{
TablePadChar: ' ',
AutoFloatPrecision: 2,
TimeFormat: "15:04:05",
TimeFormat12hr: "03:04:05pm",
DateFormat: "2006-01-02",
DateTimeFormat: "2006-01-02 15:04:05",
DateTimeFormat12hr: "2006-01-02 03:04:05pm",
ColorPathSeparator: 207,
ColorURLSeparators: BrightYellow,
ColorScheme: DarkYellow,
ColorUser: DarkGreen,
ColorPassword: DarkRed,
ColorURLPath: 128,
ColorPath: 148,
ColorQueryKey: Orange,
ColorQueryValue: DarkOrange,
ColorFragment: LightBlue,
ColorNil: DarkRed,
ColorIntNegative: Red,
ColorIntZero: Blue,
ColorIntPositive: Cyan,
ColorUintZero: Blue,
ColorUintPositive: Cyan,
ColorFloatNegative: Red,
ColorFloatZero: Blue,
ColorFloatPositive: Cyan,
ColorPercentageNegative: Red,
ColorPercentageZero: Blue - 2,
ColorPercentagePositive: Cyan - 2,
ColorBoolFalse: Red,
ColorBoolTrue: Green,
ColorTime: 26,
ColorDuration: 208,
ColorReason: Orange,
ColorFile: LightBlue,
ColorError: Red,
ColorUnitHumanReadable: 160,
ColorIndicator: DarkGray,
ColorIndicatorInfo: LightBlue,
ColorIndicatorOK: OliveGreen,
ColorIndicatorSuccess: Green,
ColorIndicatorNotOK: DarkRed,
ColorIndicatorError: Red,
ColorIndicatorWarning: Yellow,
ColorIndicatorDebug: Orange,
ColorIndicatorTrace: Orange,
ColorIndicatorProgress: LightBlue,
ColorIndicatorQuestion: Lime,
ColorsDisabled: false,
ShowRuntimeSeconds: false,
ShowRuntimeMilliseconds: true,
ShowDateTime: true,
ShowSubsystem: true,
ShowIndicator: true,
SplitOnNewLine: false, // false by default to not break old behavior
CheckIfURLIsAlive: true, // true by default to not break old behavior
ProgressBarWidth: 20,
Indicators: map[rune]*Indicator{},
reverseDNSCache: map[string]string{},
createdAt: time.Now(),
}
c.AddIndicator('✓', "[✓]", c.ColorIndicatorSuccess)
c.AddIndicator('+', "[+]", c.ColorIndicatorOK)
c.AddIndicator('i', "[i]", c.ColorIndicatorInfo)
c.AddIndicator(' ', "[ ]", c.ColorIndicator)
c.AddIndicator('_', " ", c.ColorIndicator)
c.AddIndicator('!', "[!]", c.ColorIndicatorWarning)
c.AddIndicator('-', "[-]", c.ColorIndicatorNotOK)
c.AddIndicator('x', "[x]", c.ColorIndicatorError)
c.AddIndicator('d', "[D]", c.ColorIndicatorDebug)
c.AddIndicator('?', "[?]", c.ColorIndicatorQuestion)
c.AddIndicator('t', "[T]", c.ColorIndicatorTrace)
c.AddIndicator('p', "[∞]", c.ColorIndicatorProgress)
return c
}
var LoggerConfig *Config = NewDefaultConfig()