-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogkeys.go
More file actions
104 lines (94 loc) · 2.85 KB
/
Copy pathlogkeys.go
File metadata and controls
104 lines (94 loc) · 2.85 KB
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
package logger
import "github.com/sirupsen/logrus"
const (
DefaultKeyLogLevel = logrus.FieldKeyLevel
DefaultKeyMsg = logrus.FieldKeyMsg
DefaultKeyError = "error"
DefaultKeyTime = "time"
DefaultKeyServiceName = "service_name"
DefaultKeyTransactionID = "transaction_id"
DefaultKeyUUID = "uuid"
DefaultKeyIsValid = "isValid"
DefaultKeyEventName = "event"
DefaultKeyMonitoringEvent = "monitoring_event"
DefaultKeyContentType = "content_type"
DefaultKeyEventCategory = "event_category"
DefaultKeyEventMsg = "event_msg"
)
type KeyNamesConfig struct {
KeyLogLevel string
KeyMsg string
KeyError string
KeyTime string
KeyServiceName string
KeyTransactionID string
KeyUUID string
KeyIsValid string
KeyEventName string
KeyMonitoringEvent string
KeyContentType string
KeyEventCategory string
KeyEventMsg string
}
func GetDefaultKeyNamesConfig() *KeyNamesConfig {
return &KeyNamesConfig{
KeyLogLevel: DefaultKeyLogLevel,
KeyMsg: DefaultKeyMsg,
KeyError: DefaultKeyError,
KeyTime: DefaultKeyTime,
KeyServiceName: DefaultKeyServiceName,
KeyTransactionID: DefaultKeyTransactionID,
KeyUUID: DefaultKeyUUID,
KeyIsValid: DefaultKeyIsValid,
KeyEventName: DefaultKeyEventName,
KeyMonitoringEvent: DefaultKeyMonitoringEvent,
KeyContentType: DefaultKeyContentType,
KeyEventCategory: DefaultKeyEventCategory,
KeyEventMsg: DefaultKeyEventMsg,
}
}
// GetFullKeyNameConfig returns KeyNamesConfig that has all key names from the input conf and
// if there are key names missing from the input conf, the default key names are used.
func GetFullKeyNameConfig(conf KeyNamesConfig) *KeyNamesConfig {
defaultConfig := GetDefaultKeyNamesConfig()
if conf.KeyLogLevel == "" {
conf.KeyLogLevel = defaultConfig.KeyLogLevel
}
if conf.KeyMsg == "" {
conf.KeyMsg = defaultConfig.KeyMsg
}
if conf.KeyError == "" {
conf.KeyError = defaultConfig.KeyError
}
if conf.KeyTime == "" {
conf.KeyTime = defaultConfig.KeyTime
}
if conf.KeyServiceName == "" {
conf.KeyServiceName = defaultConfig.KeyServiceName
}
if conf.KeyTransactionID == "" {
conf.KeyTransactionID = defaultConfig.KeyTransactionID
}
if conf.KeyUUID == "" {
conf.KeyUUID = defaultConfig.KeyUUID
}
if conf.KeyIsValid == "" {
conf.KeyIsValid = defaultConfig.KeyIsValid
}
if conf.KeyEventName == "" {
conf.KeyEventName = defaultConfig.KeyEventName
}
if conf.KeyMonitoringEvent == "" {
conf.KeyMonitoringEvent = defaultConfig.KeyMonitoringEvent
}
if conf.KeyContentType == "" {
conf.KeyContentType = defaultConfig.KeyContentType
}
if conf.KeyEventCategory == "" {
conf.KeyEventCategory = defaultConfig.KeyEventCategory
}
if conf.KeyEventMsg == "" {
conf.KeyEventMsg = defaultConfig.KeyEventMsg
}
return &conf
}