trashlog/wrappers/zaptg/zaptg_test.go

51 lines
849 B
Go
Raw Normal View History

2021-02-25 15:17:34 +00:00
package zaptg_test
import (
"context"
"github.com/BlackBroker/trashlog/wrappers/zaptg"
. "github.com/onsi/ginkgo"
"github.com/themakers/hlog"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var _ = Describe("Zaptg", func() {
logger, err := zap.NewProduction()
if err != nil {
panic(err)
}
logger = logger.Named("test")
ctx := context.Background()
tl, err := zaptg.NewCore(
ctx,
zap.InfoLevel,
"1408111289:AAHfWZRiBQRncb2gl2LtU8OeASjfJi4e8YE",
"v0",
"test",
0,
-1001230000451,
)
if err != nil {
panic(err)
}
logger = logger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
return zapcore.NewTee(core, tl)
}))
log := hlog.New(logger).Module("test1")
Context("Main", func() {
It("LogSomeData", func() {
log.Emit(InfoTest{Test: "test"})
})
})
})
type InfoTest struct {
Test string
}