mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
33
common/log/log_test.go
Normal file
33
common/log/log_test.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package log_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"github.com/xtls/xray-core/v1/common/log"
|
||||
"github.com/xtls/xray-core/v1/common/net"
|
||||
)
|
||||
|
||||
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),
|
||||
})
|
||||
|
||||
if diff := cmp.Diff("[Error] "+ip, logger.value); diff != "" {
|
||||
t.Error(diff)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue