-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
logKeys.go
56 lines (52 loc) · 1.44 KB
/
logKeys.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
package log
import "time"
var (
CorrelationIDKey = "correlationId"
DeviceIDKey = "deviceId"
ResourceHrefKey = "href"
CommandFilterKey = "commandFilter"
DeviceIDFilterKey = "deviceIdFilter"
ResourceIDFilterKey = "resourceIdFilter"
TypeFilterKey = "typeFilter"
EventFilterKey = "eventFilter"
SubActionKey = "subscriptionAction"
PlgdKey = "plgd"
JWTKey = "jwt"
SubKey = "sub"
RequestKey = "request"
ResponseKey = "response"
StartTimeKey = "startTime"
DeadlineKey = "deadline"
MethodKey = "method"
ProtocolKey = "protocol"
BodyKey = "body"
DurationMSKey = "durationMs"
ErrorKey = "error"
X509Key = "x509"
TraceIDKey = "traceId"
MessageKey = "message"
SubjectsKey = "subjects"
CertManagerKey = "certManager"
LocalEndpointsKey = "localEndpoints"
)
func DurationToMilliseconds(duration time.Duration) float32 {
return float32(duration.Nanoseconds()/1000) / 1000
}
func SetLogValue(m map[string]interface{}, key string, val interface{}) {
if val == nil {
return
}
if v, ok := val.(string); ok && v == "" {
return
}
if v, ok := val.([]string); ok && len(v) == 0 {
return
}
if v, ok := val.(map[string]interface{}); ok && len(v) == 0 {
return
}
if v, ok := val.(map[interface{}]interface{}); ok && len(v) == 0 {
return
}
m[key] = val
}