1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-09 17:30:44 +00:00

remove "v2ray.com/core" in log (#478)

* format errlog output

* fix test
This commit is contained in:
CalmLong 2020-12-02 20:00:51 +08:00 committed by GitHub
parent 9475e8df3c
commit 9c1ad3ab93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -37,7 +37,9 @@ func (err *Error) pkgPath() string {
if err.pathObj == nil {
return ""
}
return reflect.TypeOf(err.pathObj).PkgPath()
// remove v2ray.com/core/
oldPath := reflect.TypeOf(err.pathObj).PkgPath()
return strings.Join(strings.Split(oldPath, "/")[2:], "/")
}
// Error implements error.Error().

View File

@ -46,11 +46,11 @@ func TestErrorMessage(t *testing.T) {
}{
{
err: New("a").Base(New("b")).WithPathObj(e{}),
msg: "v2ray.com/core/common/errors_test: a > b",
msg: "common/errors_test: a > b",
},
{
err: New("a").Base(New("b").WithPathObj(e{})),
msg: "a > v2ray.com/core/common/errors_test: b",
msg: "a > common/errors_test: b",
},
}