1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-06-07 03:29:11 -04:00

refactor log and error

This commit is contained in:
Darien Raymond
2017-04-06 21:13:17 +02:00
parent fc31f9b94c
commit 75f5cb9afb
33 changed files with 123 additions and 99 deletions

View File

@@ -8,7 +8,7 @@ import (
"v2ray.com/core/testing/assert"
)
func TestActionRequired(t *testing.T) {
func TestError(t *testing.T) {
assert := assert.On(t)
err := New("TestError")
@@ -25,3 +25,25 @@ func TestActionRequired(t *testing.T) {
assert.Bool(GetSeverity(err) == SeverityWarning).IsTrue()
assert.String(err.Error()).Contains("EOF")
}
func TestErrorMessage(t *testing.T) {
assert := assert.On(t)
data := []struct {
err error
msg string
}{
{
err: New("a").Base(New("b")).Path("c", "d", "e"),
msg: "c|d|e: a > b",
},
{
err: New("a").Base(New("b").Path("c")).Path("d", "e"),
msg: "d|e: a > c: b",
},
}
for _, d := range data {
assert.String(d.err.Error()).Equals(d.msg)
}
}

View File

@@ -4,6 +4,7 @@ import (
"net"
"v2ray.com/core/app/log"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/predicate"
)
@@ -94,7 +95,7 @@ func IPAddress(ip []byte) Address {
}
return addr
default:
log.Error("Net: Invalid IP format: ", ip)
log.Trace(errors.New("Net: Invalid IP format: ", ip).AtError())
return nil
}
}