-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatter_gelf_test.go
68 lines (60 loc) · 1.78 KB
/
formatter_gelf_test.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
57
58
59
60
61
62
63
64
65
66
67
68
package gelf
import (
"strings"
"testing"
)
type gelfTest struct {
SomeVal string `json:"some_val"`
}
func TestGELFFormatter(t *testing.T) {
// l := log.New(os.Stdout, NewGELFFormatter())
// l.Print("hey there yeaaa!!!", GELF{Data: &gelfTest{SomeVal: "hey"}, Type: "TEST"})
// l = log.New(os.Stdout, log.NewStdFormatter("[%{Date} %{Time}] [%{SEVERITY}:%{File}:%{Line}] %{Message}"))
// l.Print("hey there yeaaa!!!", GELF{Data: &gelfTest{SomeVal: "hey"}, Type: "TEST"})
}
func toLower(s string) string {
b := make([]byte, len(s))
for i := range b {
c := s[i]
if c >= 'A' && c <= 'Z' {
c += 'a' - 'A'
}
b[i] = c
}
return string(b)
}
func BenchmarkCopyMapDelete(b *testing.B) {
original := map[string]interface{}{
"Accept": []string{"*/*"},
"Content-Length": []string{"529"},
"Content-Type": []string{"application/x-www-form-urlencoded"},
"User-Agent": []string{"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3"},
"authorization": "caca",
}
for x := 0; x < b.N; x++ {
newmap := make(map[string]interface{})
for k, v := range original {
newmap[k] = v
}
delete(newmap, "Authorization")
delete(newmap, "authorization")
}
}
func BenchmarkCopyMapTestDelete(b *testing.B) {
original := map[string]interface{}{
"Accept": []string{"*/*"},
"Content-Length": []string{"529"},
"Content-Type": []string{"application/x-www-form-urlencoded"},
"User-Agent": []string{"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3"},
"authorization": "caca",
}
for x := 0; x < b.N; x++ {
newmap := make(map[string]interface{})
for k, v := range original {
if strings.EqualFold(k, "authorization") {
continue
}
newmap[k] = v
}
}
}