-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
logKeys.go
48 lines (44 loc) · 1.15 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
package log
import "time"
var CorrelationIDKey = "correlationId"
var DeviceIDKey = "deviceId"
var ResourceHrefKey = "href"
var JWTSubKey = "jwt.sub"
var CommandFilterKey = "commandFilter"
var DeviceIDFilterKey = "deviceIdFilter"
var ResourceIDFilterKey = "resourceIdFilter"
var TypeFilterKey = "typeFilter"
var EventFilterKey = "eventFilter"
var SubActionKey = "subscriptionAction"
var PlgdKey = "plgd"
var JWTKey = "jwt"
var SubKey = "sub"
var RequestKey = "request"
var ResponseKey = "response"
var StartTimeKey = "startTime"
var DeadlineKey = "deadline"
var MethodKey = "method"
var ProtocolKey = "protocol"
var BodyKey = "body"
var DurationMSKey = "durationMs"
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
}