@@ -2,7 +2,6 @@ package logutils
2
2
3
3
import (
4
4
"bytes"
5
- "fmt"
6
5
"strings"
7
6
"sync"
8
7
"testing"
@@ -30,35 +29,25 @@ func TestCore(t *testing.T) {
30
29
childWithMoreContext := childWithContext .With (zap .String ("key2" , "value2" ))
31
30
grandChild := childWithMoreContext .Named ("grandChild" )
32
31
33
- parent .Debug ("Status" )
34
- child .Debug ("Super" )
35
- childWithContext .Debug ("App" )
36
- childWithMoreContext .Debug ("The" )
37
- grandChild .Debug ("Best" )
38
-
39
- core .UpdateSyncer (zapcore .AddSync (buffer2 ))
40
- core .UpdateEncoder (zapcore .NewJSONEncoder (zap .NewProductionEncoderConfig ()))
41
-
42
- parent .Debug ("Status" )
43
- child .Debug ("Super" )
44
- childWithContext .Debug ("App" )
45
- childWithMoreContext .Debug ("The" )
46
- grandChild .Debug ("Best" )
47
-
48
- fmt .Println (buffer1 .String ())
49
- fmt .Println (buffer2 .String ())
32
+ print := func () {
33
+ parent .Debug ("Status" )
34
+ child .Debug ("Super" )
35
+ childWithContext .Debug ("App" )
36
+ childWithMoreContext .Debug ("The" )
37
+ grandChild .Debug ("Best" )
38
+ }
50
39
51
40
// Ensure that the first buffer has the console encoder output
41
+ print ()
52
42
buffer1Lines := strings .Split (buffer1 .String (), "\n " )
53
43
require .Len (t , buffer1Lines , 5 + 1 )
54
44
require .Regexp (t , `\s+child\s+` , buffer1Lines [1 ])
55
45
require .Regexp (t , `\s+child\.grandChild\s+` , buffer1Lines [4 ])
56
46
57
- // Ensure that the second buffer has the JSON encoder output
58
- buffer2Lines := strings .Split (buffer2 .String (), "\n " )
59
- require .Len (t , buffer2Lines , 5 + 1 )
60
- require .Regexp (t , `"logger"\s*:\s*"child"` , buffer2Lines [1 ])
61
- require .Regexp (t , `"logger"\s*:\s*"child\.grandChild"` , buffer2Lines [4 ])
47
+ // Ensure syncer was updated
48
+ core .UpdateSyncer (zapcore .AddSync (buffer2 ))
49
+ print ()
50
+ require .Equal (t , buffer1 , buffer2 )
62
51
}
63
52
64
53
func benchmarkCore (b * testing.B , core zapcore.Core ) {
0 commit comments