...
1 package mocktracer
2
3 import (
4 "fmt"
5 "reflect"
6 "time"
7
8 "github.com/opentracing/opentracing-go/log"
9 )
10
11
12
13 type MockLogRecord struct {
14 Timestamp time.Time
15 Fields []MockKeyValue
16 }
17
18
19 type MockKeyValue struct {
20 Key string
21
22
23
24 ValueKind reflect.Kind
25 ValueString string
26 }
27
28
29 func (m *MockKeyValue) EmitString(key, value string) {
30 m.Key = key
31 m.ValueKind = reflect.TypeOf(value).Kind()
32 m.ValueString = fmt.Sprint(value)
33 }
34
35
36 func (m *MockKeyValue) EmitBool(key string, value bool) {
37 m.Key = key
38 m.ValueKind = reflect.TypeOf(value).Kind()
39 m.ValueString = fmt.Sprint(value)
40 }
41
42
43 func (m *MockKeyValue) EmitInt(key string, value int) {
44 m.Key = key
45 m.ValueKind = reflect.TypeOf(value).Kind()
46 m.ValueString = fmt.Sprint(value)
47 }
48
49
50 func (m *MockKeyValue) EmitInt32(key string, value int32) {
51 m.Key = key
52 m.ValueKind = reflect.TypeOf(value).Kind()
53 m.ValueString = fmt.Sprint(value)
54 }
55
56
57 func (m *MockKeyValue) EmitInt64(key string, value int64) {
58 m.Key = key
59 m.ValueKind = reflect.TypeOf(value).Kind()
60 m.ValueString = fmt.Sprint(value)
61 }
62
63
64 func (m *MockKeyValue) EmitUint32(key string, value uint32) {
65 m.Key = key
66 m.ValueKind = reflect.TypeOf(value).Kind()
67 m.ValueString = fmt.Sprint(value)
68 }
69
70
71 func (m *MockKeyValue) EmitUint64(key string, value uint64) {
72 m.Key = key
73 m.ValueKind = reflect.TypeOf(value).Kind()
74 m.ValueString = fmt.Sprint(value)
75 }
76
77
78 func (m *MockKeyValue) EmitFloat32(key string, value float32) {
79 m.Key = key
80 m.ValueKind = reflect.TypeOf(value).Kind()
81 m.ValueString = fmt.Sprint(value)
82 }
83
84
85 func (m *MockKeyValue) EmitFloat64(key string, value float64) {
86 m.Key = key
87 m.ValueKind = reflect.TypeOf(value).Kind()
88 m.ValueString = fmt.Sprint(value)
89 }
90
91
92 func (m *MockKeyValue) EmitObject(key string, value interface{}) {
93 m.Key = key
94 m.ValueKind = reflect.TypeOf(value).Kind()
95 m.ValueString = fmt.Sprint(value)
96 }
97
98
99 func (m *MockKeyValue) EmitLazyLogger(value log.LazyLogger) {
100 var meta MockKeyValue
101 value(&meta)
102 m.Key = meta.Key
103 m.ValueKind = meta.ValueKind
104 m.ValueString = meta.ValueString
105 }
106
View as plain text