Debian Codegraph @

entry_test.go

raw symbols SCIP
1 package logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.13 bytes/"
5 "contextscip-go gomod github.com/golang/go/src go1.13 context/"
6 "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/"
7 "testingscip-go gomod github.com/golang/go/src go1.13 testing/"
8 "timescip-go gomod github.com/golang/go/src go1.13 time/"
9
10 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/"
11 )
12
13 func TestEntryWithErrorscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryWithError().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
14
15 assert := assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/New().(t)
16
17 defer func() {
18 ErrorKeyscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/ErrorKey. = "error"
19 }()
20
21 err := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("kaboom at layer %d", 4711)
22
23 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(err, WithErrorscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/WithError().(err).Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["error"])
24
25 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
26 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
27 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
28
29 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(err, entry.WithErrorscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithError().(err).Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["error"])
30
31 ErrorKeyscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/ErrorKey. = "err"
32
33 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(err, entry.WithErrorscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithError().(err).Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["err"])
34
35 }
36
37 func TestEntryWithContextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryWithContext().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
38 assert := assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/New().(t)
39 ctx := contextscip-go gomod github.com/golang/go/src go1.13 context/.WithValuescip-go gomod github.com/golang/go/src go1.13 context/WithValue().(contextscip-go gomod github.com/golang/go/src go1.13 context/.Backgroundscip-go gomod github.com/golang/go/src go1.13 context/Background().(), "foo", "bar")
40
41 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(ctx, WithContextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/WithContext().(ctx).Contextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Context.)
42
43 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
44 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
45 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
46
47 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(ctx, entry.WithContextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithContext().(ctx).Contextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Context.)
48 }
49
50 func TestEntryWithContextCopiesDatascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryWithContextCopiesData().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
51 assert := assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/New().(t)
52
53 // Initialize a parent Entry object with a key/value set in its Data map
54 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
55 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
56 parentEntry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger).WithFieldscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithField().("parentKey", "parentValue")
57
58 // Create two children Entry objects from the parent in different contexts
59 ctx1 := contextscip-go gomod github.com/golang/go/src go1.13 context/.WithValuescip-go gomod github.com/golang/go/src go1.13 context/WithValue().(contextscip-go gomod github.com/golang/go/src go1.13 context/.Backgroundscip-go gomod github.com/golang/go/src go1.13 context/Background().(), "foo", "bar")
60 childEntry1 := parentEntry.WithContextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithContext().(ctx1)
61 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(ctx1, childEntry1.Contextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Context.)
62
63 ctx2 := contextscip-go gomod github.com/golang/go/src go1.13 context/.WithValuescip-go gomod github.com/golang/go/src go1.13 context/WithValue().(contextscip-go gomod github.com/golang/go/src go1.13 context/.Backgroundscip-go gomod github.com/golang/go/src go1.13 context/Background().(), "bar", "baz")
64 childEntry2 := parentEntry.WithContextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithContext().(ctx2)
65 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(ctx2, childEntry2.Contextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Context.)
66 assert.NotEqualscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#NotEqual().(ctx1, ctx2)
67
68 // Ensure that data set in the parent Entry are preserved to both children
69 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("parentValue", childEntry1.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["parentKey"])
70 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("parentValue", childEntry2.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["parentKey"])
71
72 // Modify data stored in the child entry
73 childEntry1.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["childKey"] = "childValue"
74
75 // Verify that data is successfully stored in the child it was set on
76 val, exists := childEntry1.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["childKey"]
77 assert.Truescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#True().(exists)
78 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("childValue", val)
79
80 // Verify that the data change to child 1 has not affected its sibling
81 val, exists = childEntry2.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["childKey"]
82 assert.Falsescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#False().(exists)
83 assert.Emptyscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Empty().(val)
84
85 // Verify that the data change to child 1 has not affected its parent
86 val, exists = parentEntry.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["childKey"]
87 assert.Falsescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#False().(exists)
88 assert.Emptyscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Empty().(val)
89 }
90
91 func TestEntryWithTimeCopiesDatascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryWithTimeCopiesData().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
92 assert := assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/New().(t)
93
94 // Initialize a parent Entry object with a key/value set in its Data map
95 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
96 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
97 parentEntry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger).WithFieldscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithField().("parentKey", "parentValue")
98
99 // Create two children Entry objects from the parent with two different times
100 childEntry1 := parentEntry.WithTimescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithTime().(timescip-go gomod github.com/golang/go/src go1.13 time/.Nowscip-go gomod github.com/golang/go/src go1.13 time/Now().().AddDatescip-go gomod github.com/golang/go/src go1.13 time/Time#AddDate().(0, 0, 1))
101 childEntry2 := parentEntry.WithTimescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithTime().(timescip-go gomod github.com/golang/go/src go1.13 time/.Nowscip-go gomod github.com/golang/go/src go1.13 time/Now().().AddDatescip-go gomod github.com/golang/go/src go1.13 time/Time#AddDate().(0, 0, 2))
102
103 // Ensure that data set in the parent Entry are preserved to both children
104 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("parentValue", childEntry1.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["parentKey"])
105 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("parentValue", childEntry2.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["parentKey"])
106
107 // Modify data stored in the child entry
108 childEntry1.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["childKey"] = "childValue"
109
110 // Verify that data is successfully stored in the child it was set on
111 val, exists := childEntry1.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["childKey"]
112 assert.Truescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#True().(exists)
113 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().("childValue", val)
114
115 // Verify that the data change to child 1 has not affected its sibling
116 val, exists = childEntry2.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["childKey"]
117 assert.Falsescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#False().(exists)
118 assert.Emptyscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Empty().(val)
119
120 // Verify that the data change to child 1 has not affected its parent
121 val, exists = parentEntry.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["childKey"]
122 assert.Falsescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#False().(exists)
123 assert.Emptyscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Empty().(val)
124 }
125
126 func TestEntryPaniclnscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryPanicln().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
127 errBoom := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("boom time")
128
129 defer func() {
130 p := recover()
131 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/NotNil().(t, p)
132
133 switch pVal := p.(type) {
134 case *Entryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#:
135 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, "kaboom", pVal.Messagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Message.)
136 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, errBoom, pVal.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["err"])
137 default:
138 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("want type *Entry, got %T: %#v", pVal, pVal)
139 }
140 }()
141
142 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
143 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
144 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
145 entry.WithFieldscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithField().("err", errBoom).Paniclnscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Panicln().("kaboom")
146 }
147
148 func TestEntryPanicfscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryPanicf().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
149 errBoom := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("boom again")
150
151 defer func() {
152 p := recover()
153 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/NotNil().(t, p)
154
155 switch pVal := p.(type) {
156 case *Entryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#:
157 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, "kaboom true", pVal.Messagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Message.)
158 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, errBoom, pVal.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["err"])
159 default:
160 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("want type *Entry, got %T: %#v", pVal, pVal)
161 }
162 }()
163
164 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
165 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
166 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
167 entry.WithFieldscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithField().("err", errBoom).Panicfscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Panicf().("kaboom %v", true)
168 }
169
170 func TestEntryPanicscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryPanic().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
171 errBoom := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("boom again")
172
173 defer func() {
174 p := recover()
175 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/NotNil().(t, p)
176
177 switch pVal := p.(type) {
178 case *Entryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#:
179 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, "kaboom", pVal.Messagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Message.)
180 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, errBoom, pVal.Datascip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Data.["err"])
181 default:
182 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("want type *Entry, got %T: %#v", pVal, pVal)
183 }
184 }()
185
186 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
187 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
188 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
189 entry.WithFieldscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithField().("err", errBoom).Panicscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Panic().("kaboom")
190 }
191
192 const (
193 badMessagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/badMessage. = "this is going to panic"
194 panicMessagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panicMessage. = "this is broken"
195 )
196
197 type panickyHookscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panickyHook# struct{}
198
199 func (p *panickyHookscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panickyHook#) Levelsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panickyHook#Levels().() []Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level# {
200 return []Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#{InfoLevelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/InfoLevel.}
201 }
202
203 func (p *panickyHookscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panickyHook#) Firescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panickyHook#Fire().(entry *Entryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#) error {
204 if entry.Messagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Message. == badMessagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/badMessage. {
205 panic(panicMessagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panicMessage.)
206 }
207
208 return nil
209 }
210
211 func TestEntryHooksPanicscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryHooksPanic().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
212 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
213 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
214 logger.Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Level. = InfoLevelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/InfoLevel.
215 logger.Hooksscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Hooks..Addscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/LevelHooks#Add().(&panickyHookscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panickyHook#{})
216
217 defer func() {
218 p := recover()
219 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/NotNil().(t, p)
220 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, panicMessagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/panicMessage., p)
221
222 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
223 entry.Infoscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Info().("another message")
224 }()
225
226 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
227 entry.Infoscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Info().(badMessagescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/badMessage.)
228 }
229
230 func TestEntryWithIncorrectFieldscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryWithIncorrectField().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
231 assert := assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/New().(t)
232
233 fn := func() {}
234
235 e := Entryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#{Loggerscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Logger.: Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()}
236 eWithFunc := e.WithFieldsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithFields().(Fieldsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Fields#{"func": fn})
237 eWithFuncPtr := e.WithFieldsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithFields().(Fieldsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Fields#{"funcPtr": &fn})
238
239 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(eWithFunc.errscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#err., `can not add field "func"`)
240 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(eWithFuncPtr.errscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#err., `can not add field "funcPtr"`)
241
242 eWithFunc = eWithFunc.WithFieldscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithField().("not_a_func", "it is a string")
243 eWithFuncPtr = eWithFuncPtr.WithFieldscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithField().("not_a_func", "it is a string")
244
245 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(eWithFunc.errscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#err., `can not add field "func"`)
246 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(eWithFuncPtr.errscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#err., `can not add field "funcPtr"`)
247
248 eWithFunc = eWithFunc.WithTimescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithTime().(timescip-go gomod github.com/golang/go/src go1.13 time/.Nowscip-go gomod github.com/golang/go/src go1.13 time/Now().())
249 eWithFuncPtr = eWithFuncPtr.WithTimescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#WithTime().(timescip-go gomod github.com/golang/go/src go1.13 time/.Nowscip-go gomod github.com/golang/go/src go1.13 time/Now().())
250
251 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(eWithFunc.errscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#err., `can not add field "func"`)
252 assert.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(eWithFuncPtr.errscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#err., `can not add field "funcPtr"`)
253 }
254
255 func TestEntryLogfLevelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryLogfLevel().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
256 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
257 buffer := &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{}
258 logger.Outscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#Out. = buffer
259 logger.SetLevelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#SetLevel().(InfoLevelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/InfoLevel.)
260 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
261
262 entry.Logfscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Logf().(DebugLevelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/DebugLevel., "%s", "debug")
263 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.NotContainsscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/NotContains().(t, buffer.Stringscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#String().(), "debug")
264
265 entry.Logfscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Logf().(WarnLevelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/WarnLevel., "%s", "warn")
266 assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Contains().(t, buffer.Stringscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#String().(), "warn")
267 }
268
269 func TestEntryReportCallerRacescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryReportCallerRace().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
270 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
271 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
272
273 // logging before SetReportCaller has the highest chance of causing a race condition
274 // to be detected, but doing it twice just to increase the likelyhood of detecting the race
275 go func() {
276 entry.Infoscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Info().("should not race")
277 }()
278 go func() {
279 logger.SetReportCallerscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#SetReportCaller().(true)
280 }()
281 go func() {
282 entry.Infoscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Info().("should not race")
283 }()
284 }
285
286 func TestEntryFormatterRacescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TestEntryFormatterRace().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
287 logger := Newscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/New().()
288 entry := NewEntryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/NewEntry().(logger)
289
290 // logging before SetReportCaller has the highest chance of causing a race condition
291 // to be detected, but doing it twice just to increase the likelyhood of detecting the race
292 go func() {
293 entry.Infoscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Info().("should not race")
294 }()
295 go func() {
296 logger.SetFormatterscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Logger#SetFormatter().(&TextFormatterscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/TextFormatter#{})
297 }()
298 go func() {
299 entry.Infoscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#Info().("should not race")
300 }()
301 }