0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-14 20:39:36 +03: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:
yuhan6665
2024-06-29 14:32:57 -04:00
committed by GitHub
parent 8320732743
commit 079d0bd8a9
291 changed files with 1837 additions and 2368 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/protocol/udp"
"github.com/xtls/xray-core/transport/internet"
@ -54,7 +55,7 @@ func ListenUDP(ctx context.Context, address net.Address, port net.Port, streamSe
if err != nil {
return nil, err
}
newError("listening UDP on ", address, ":", port).WriteToLog()
errors.LogInfo(ctx, "listening UDP on ", address, ":", port)
hub.conn = udpConn.(*net.UDPConn)
hub.cache = make(chan *udp.Packet, hub.capacity)
@ -89,7 +90,7 @@ func (h *Hub) start() {
n, noob, _, addr, err := ReadUDPMsg(h.conn, rawBytes, oobBytes)
if err != nil {
newError("failed to read UDP msg").Base(err).WriteToLog()
errors.LogInfoInner(context.Background(), err, "failed to read UDP msg")
buffer.Release()
break
}
@ -107,9 +108,9 @@ func (h *Hub) start() {
if h.recvOrigDest && noob > 0 {
payload.Target = RetrieveOriginalDest(oobBytes[:noob])
if payload.Target.IsValid() {
newError("UDP original destination: ", payload.Target).AtDebug().WriteToLog()
errors.LogDebug(context.Background(), "UDP original destination: ", payload.Target)
} else {
newError("failed to read UDP original destination").WriteToLog()
errors.LogInfo(context.Background(), "failed to read UDP original destination")
}
}