You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/log/helper_test.go

46 lines
941 B

4 years ago
package log
import (
"io/ioutil"
4 years ago
"testing"
)
func TestHelper(t *testing.T) {
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
log := NewHelper(logger)
log.Log(LevelDebug, "msg", "test debug")
4 years ago
log.Debug("test debug")
log.Debugf("test %s", "debug")
log.Debugw("log", "test debug")
}
func TestHelperLevel(t *testing.T) {
log := NewHelper(DefaultLogger)
4 years ago
log.Debug("test debug")
log.Info("test info")
log.Warn("test warn")
log.Error("test error")
}
func BenchmarkHelperPrint(b *testing.B) {
log := NewHelper(NewStdLogger(ioutil.Discard))
for i := 0; i < b.N; i++ {
log.Debug("test")
}
}
func BenchmarkHelperPrintf(b *testing.B) {
log := NewHelper(NewStdLogger(ioutil.Discard))
for i := 0; i < b.N; i++ {
log.Debugf("%s", "test")
}
}
func BenchmarkHelperPrintw(b *testing.B) {
log := NewHelper(NewStdLogger(ioutil.Discard))
for i := 0; i < b.N; i++ {
log.Debugw("key", "value")
}
}