1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-29 02:35:23 +00:00
v2fly/common/log/log_test.go

34 lines
576 B
Go
Raw Normal View History

2017-12-10 21:48:28 +00:00
package log_test
import (
"testing"
2018-11-15 10:17:20 +00:00
"github.com/google/go-cmp/cmp"
2021-02-16 20:31:50 +00:00
"github.com/v2fly/v2ray-core/v4/common/log"
"github.com/v2fly/v2ray-core/v4/common/net"
2017-12-10 21:48:28 +00:00
)
type testLogger struct {
value string
}
func (l *testLogger) Handle(msg log.Message) {
l.value = msg.String()
}
func TestLogRecord(t *testing.T) {
var logger testLogger
log.RegisterHandler(&logger)
ip := "8.8.8.8"
log.Record(&log.GeneralMessage{
Severity: log.Severity_Error,
Content: net.ParseAddress(ip),
})
2018-11-15 10:17:20 +00:00
if diff := cmp.Diff("[Error] "+ip, logger.value); diff != "" {
t.Error(diff)
2018-07-13 12:36:09 +00:00
}
2017-12-10 21:48:28 +00:00
}