2024-01-22 18:05:51 +08:00
|
|
|
package loggerx_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"testing"
|
2024-01-23 13:37:51 +08:00
|
|
|
"time"
|
2024-01-22 18:05:51 +08:00
|
|
|
|
|
|
|
|
"code.yun.ink/pkg/loggerx"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// func TestMain(m *testing.M) {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
func TestLogger(t *testing.T) {
|
|
|
|
|
|
2024-01-23 00:12:08 +08:00
|
|
|
l := loggerx.NewLogger(loggerx.SetErrorToInfo())
|
2024-01-22 18:05:51 +08:00
|
|
|
|
|
|
|
|
l.Error(context.Background(), "test error")
|
|
|
|
|
|
2024-01-23 00:12:08 +08:00
|
|
|
l.Channel("test").Error(context.Background(), "test error")
|
|
|
|
|
|
|
|
|
|
l.Info(context.Background(), "test info")
|
|
|
|
|
|
2024-01-23 13:37:51 +08:00
|
|
|
time.Sleep(time.Second * 2)
|
2024-01-22 18:05:51 +08:00
|
|
|
}
|