mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 01:08:33 +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
|
@ -6,8 +6,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/grpc/encoding"
|
||||
"github.com/xtls/xray-core/transport/internet/reality"
|
||||
|
@ -94,7 +94,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i
|
|||
listener.s = s
|
||||
|
||||
if settings.SocketSettings != nil && settings.SocketSettings.AcceptProxyProtocol {
|
||||
newError("accepting PROXY protocol").AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
||||
errors.LogWarning(ctx, "accepting PROXY protocol")
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
@ -106,7 +106,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i
|
|||
Net: "unix",
|
||||
}, settings.SocketSettings)
|
||||
if err != nil {
|
||||
newError("failed to listen on ", address).Base(err).AtError().WriteToLog(session.ExportIDToError(ctx))
|
||||
errors.LogErrorInner(ctx, err, "failed to listen on ", address)
|
||||
return
|
||||
}
|
||||
} else { // tcp
|
||||
|
@ -115,19 +115,19 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i
|
|||
Port: int(port),
|
||||
}, settings.SocketSettings)
|
||||
if err != nil {
|
||||
newError("failed to listen on ", address, ":", port).Base(err).AtError().WriteToLog(session.ExportIDToError(ctx))
|
||||
errors.LogErrorInner(ctx, err, "failed to listen on ", address, ":", port)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
newError("gRPC listen for service name `" + grpcSettings.getServiceName() + "` tun `" + grpcSettings.getTunStreamName() + "` multi tun `" + grpcSettings.getTunMultiStreamName() + "`").AtDebug().WriteToLog()
|
||||
errors.LogDebug(ctx, "gRPC listen for service name `" + grpcSettings.getServiceName() + "` tun `" + grpcSettings.getTunStreamName() + "` multi tun `" + grpcSettings.getTunMultiStreamName() + "`")
|
||||
encoding.RegisterGRPCServiceServerX(s, listener, grpcSettings.getServiceName(), grpcSettings.getTunStreamName(), grpcSettings.getTunMultiStreamName())
|
||||
|
||||
if config := reality.ConfigFromStreamSettings(settings); config != nil {
|
||||
streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig())
|
||||
}
|
||||
if err = s.Serve(streamListener); err != nil {
|
||||
newError("Listener for gRPC ended").Base(err).WriteToLog()
|
||||
errors.LogInfoInner(ctx, err, "Listener for gRPC ended")
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue