@@ -21,7 +21,6 @@ func TestVisual(t *testing.T) {
2121 hue .Enabled (true ) // Force colour
2222
2323 logger := log .New (os .Stdout , log .WithLevel (log .LevelDebug ))
24-
2524 prefixed := logger .Prefixed ("cooking" )
2625
2726 logger .Debug ("Doing some debuggy things" )
@@ -192,7 +191,7 @@ func TestRace(t *testing.T) {
192191 logger := log .New (buf , log .TimeFunc (fixedTime ))
193192 sub := logger .Prefixed ("sub" )
194193
195- const n = 5
194+ const n = 1000
196195
197196 var wg sync.WaitGroup
198197 wg .Add (n )
@@ -224,46 +223,6 @@ func TestRace(t *testing.T) {
224223 test .Equal (t , len (lines ), n * 2 , test .Context ("expected %d log lines" , n * 2 ))
225224}
226225
227- func TestContext (t * testing.T ) {
228- t .Run ("present" , func (t * testing.T ) {
229- buf := & bytes.Buffer {}
230-
231- // Constantly return the same time
232- fixedTime := func () time.Time {
233- fixed , err := time .Parse (time .RFC3339 , "2025-04-01T13:34:03Z" )
234- test .Ok (t , err )
235-
236- return fixed
237- }
238-
239- // Configure it a bit so we know we're getting the right one
240- logger := log .New (buf , log .TimeFunc (fixedTime ), log .TimeFormat (time .Kitchen ))
241-
242- logger .Info ("Before" )
243-
244- ctx := t .Context ()
245-
246- ctx = log .WithContext (ctx , logger )
247-
248- after := log .FromContext (ctx )
249-
250- after .Info ("After" )
251-
252- got := buf .String ()
253-
254- test .Diff (t , got , "1:34PM INFO: Before\n 1:34PM INFO: After\n " )
255- })
256-
257- t .Run ("missing" , func (t * testing.T ) {
258- _ , stderr := test .CaptureOutput (t , func () error {
259- log .FromContext (t .Context ()).Info ("FromContext" )
260- return nil
261- })
262-
263- test .True (t , strings .Contains (stderr , "FromContext" ))
264- })
265- }
266-
267226func BenchmarkLogger (b * testing.B ) {
268227 hue .Enabled (true ) // Force colour
269228
0 commit comments