Skip to content

Commit 0ae9972

Browse files
committed
fix: cannot call SetPrimaryCore after using a Tee logger
Signed-off-by: Manfred Touron <[email protected]>
1 parent 73fb407 commit 0ae9972

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

setup_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77
"os"
88
"strings"
99
"testing"
10+
11+
"go.uber.org/zap"
12+
"go.uber.org/zap/zapcore"
1013
)
1114

1215
func TestGetLoggerDefault(t *testing.T) {
@@ -240,3 +243,18 @@ func TestCustomCore(t *testing.T) {
240243
t.Errorf("got %q, wanted it to contain log output", buf2.String())
241244
}
242245
}
246+
247+
func TestTeeCore(t *testing.T) {
248+
// configure to use a tee logger
249+
tee := zap.New(zapcore.NewTee(
250+
zap.NewNop().Core(),
251+
zap.NewNop().Core(),
252+
), zap.AddCaller())
253+
SetPrimaryCore(tee.Core())
254+
log := getLogger("test")
255+
log.Error("scooby")
256+
257+
// replaces the tee logger with a simple one
258+
SetPrimaryCore(zap.NewNop().Core())
259+
log.Error("doo")
260+
}

0 commit comments

Comments
 (0)