mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-19 01:38:40 +00:00
Refactor log (#3446)
* Refactor log * Add new log methods * Fix logger test * Change all logging code * Clean up pathObj * Rebase to latest main * Remove invoking method name after the dot
This commit is contained in:
parent
8320732743
commit
079d0bd8a9
291 changed files with 1837 additions and 2368 deletions
|
@ -8,8 +8,8 @@ import (
|
|||
|
||||
goreality "github.com/xtls/reality"
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/common/session"
|
||||
"github.com/xtls/xray-core/transport/internet"
|
||||
"github.com/xtls/xray-core/transport/internet/reality"
|
||||
"github.com/xtls/xray-core/transport/internet/stat"
|
||||
|
@ -47,22 +47,22 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, streamSe
|
|||
Net: "unix",
|
||||
}, streamSettings.SocketSettings)
|
||||
if err != nil {
|
||||
return nil, newError("failed to listen Unix Domain Socket on ", address).Base(err)
|
||||
return nil, errors.New("failed to listen Unix Domain Socket on ", address).Base(err)
|
||||
}
|
||||
newError("listening Unix Domain Socket on ", address).WriteToLog(session.ExportIDToError(ctx))
|
||||
errors.LogInfo(ctx, "listening Unix Domain Socket on ", address)
|
||||
} else {
|
||||
listener, err = internet.ListenSystem(ctx, &net.TCPAddr{
|
||||
IP: address.IP(),
|
||||
Port: int(port),
|
||||
}, streamSettings.SocketSettings)
|
||||
if err != nil {
|
||||
return nil, newError("failed to listen TCP on ", address, ":", port).Base(err)
|
||||
return nil, errors.New("failed to listen TCP on ", address, ":", port).Base(err)
|
||||
}
|
||||
newError("listening TCP on ", address, ":", port).WriteToLog(session.ExportIDToError(ctx))
|
||||
errors.LogInfo(ctx, "listening TCP on ", address, ":", port)
|
||||
}
|
||||
|
||||
if streamSettings.SocketSettings != nil && streamSettings.SocketSettings.AcceptProxyProtocol {
|
||||
newError("accepting PROXY protocol").AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
||||
errors.LogWarning(ctx, "accepting PROXY protocol")
|
||||
}
|
||||
|
||||
l.listener = listener
|
||||
|
@ -77,11 +77,11 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, streamSe
|
|||
if tcpSettings.HeaderSettings != nil {
|
||||
headerConfig, err := tcpSettings.HeaderSettings.GetInstance()
|
||||
if err != nil {
|
||||
return nil, newError("invalid header settings").Base(err).AtError()
|
||||
return nil, errors.New("invalid header settings").Base(err).AtError()
|
||||
}
|
||||
auth, err := internet.CreateConnectionAuthenticator(headerConfig)
|
||||
if err != nil {
|
||||
return nil, newError("invalid header settings.").Base(err).AtError()
|
||||
return nil, errors.New("invalid header settings.").Base(err).AtError()
|
||||
}
|
||||
l.authConfig = auth
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func (v *Listener) keepAccepting() {
|
|||
if strings.Contains(errStr, "closed") {
|
||||
break
|
||||
}
|
||||
newError("failed to accepted raw connections").Base(err).AtWarning().WriteToLog()
|
||||
errors.LogWarningInner(context.Background(), err, "failed to accepted raw connections")
|
||||
if strings.Contains(errStr, "too many") {
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func (v *Listener) keepAccepting() {
|
|||
conn = tls.Server(conn, v.tlsConfig)
|
||||
} else if v.realityConfig != nil {
|
||||
if conn, err = reality.Server(conn, v.realityConfig); err != nil {
|
||||
newError(err).AtInfo().WriteToLog()
|
||||
errors.LogInfo(context.Background(), err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue