2020-02-09 19:46:33 +03:00
|
|
|
package zap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/micro/go-micro/v2/logger"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestName(t *testing.T) {
|
|
|
|
l, err := NewLogger()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if l.String() != "zap" {
|
|
|
|
t.Errorf("name is error %s", l.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("test logger name: %s", l.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLogf(t *testing.T) {
|
|
|
|
l, err := NewLogger()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-02-21 12:31:16 +03:00
|
|
|
logger.DefaultLogger = l
|
|
|
|
logger.Logf(logger.InfoLevel, "test logf: %s", "name")
|
2020-02-09 19:46:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSetLevel(t *testing.T) {
|
|
|
|
l, err := NewLogger()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-02-21 12:31:16 +03:00
|
|
|
logger.DefaultLogger = l
|
2020-02-09 19:46:33 +03:00
|
|
|
|
2020-02-21 12:31:16 +03:00
|
|
|
logger.Init(logger.WithLevel(logger.DebugLevel))
|
2020-02-09 19:46:33 +03:00
|
|
|
l.Logf(logger.DebugLevel, "test show debug: %s", "debug msg")
|
|
|
|
|
2020-02-21 12:31:16 +03:00
|
|
|
logger.Init(logger.WithLevel(logger.InfoLevel))
|
2020-02-09 19:46:33 +03:00
|
|
|
l.Logf(logger.DebugLevel, "test non-show debug: %s", "debug msg")
|
|
|
|
}
|