-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.go
53 lines (47 loc) · 1.26 KB
/
parser.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
package elblog
import (
"fmt"
"github.com/pshevtsov/gonx"
)
var (
FieldTimestamp = "timestamp"
FieldELB = "elb"
FieldClient = "client"
FieldBackend = "backend"
FieldRequestProcessingTime = "request_processing_time"
FieldBackendProcessingTime = "backend_processing_time"
FieldResponseProcessingTime = "response_processing_time"
FieldELBStatus = "elb_status_code"
FieldBackendStatus = "backend_status_code"
FieldReceivedBytes = "received_bytes"
FieldSentBytes = "sent_bytes"
FieldRequest = "request"
)
type field string
func (f field) String() string {
s := string(f)
switch s {
case FieldRequest:
return fmt.Sprintf(`"$%s"`, s)
}
return fmt.Sprint("$", s)
}
func NewParser() *gonx.Parser {
slice := []field{
field(FieldTimestamp),
field(FieldELB),
field(FieldClient),
field(FieldBackend),
field(FieldRequestProcessingTime),
field(FieldBackendProcessingTime),
field(FieldResponseProcessingTime),
field(FieldELBStatus),
field(FieldBackendStatus),
field(FieldReceivedBytes),
field(FieldSentBytes),
field(FieldRequest),
}
format := fmt.Sprint(slice)
format = format[1 : len(format)-1]
return gonx.NewParser(format)
}