-
Notifications
You must be signed in to change notification settings - Fork 0
/
field.go
40 lines (36 loc) · 1.01 KB
/
field.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
package eglm
import (
"encoding/json"
)
// AccessLogField echo default log fields.
type AccessLogField struct {
Type string `json:"type"`
Status int `json:"status"`
Method string `json:"method"`
Path string `json:"path"`
UserAgent string `json:"userAgent"`
RemoteIP string `json:"remoteIp"`
ForwardedFor string `json:"forwardedFor"`
Elapsed int `json:"elapsed"`
Error string `json:"error"`
RequestID string `json:"requestId"`
}
// ToMap struct attributes to map
func (a *AccessLogField) ToMap() map[string]interface{} {
return map[string]interface{}{
"type": a.Type,
"status": a.Status,
"method": a.Method,
"path": a.Path,
"userAgent": a.UserAgent,
"remoteIp": a.RemoteIP,
"forwardedFor": a.ForwardedFor,
"elapsed": a.Elapsed,
"error": a.Error,
"requestId": a.RequestID,
}
}
// ToJSON struct attributes to json
func (a *AccessLogField) ToJSON() ([]byte, error) {
return json.Marshal(a)
}