fix: tx-debug-udp 日志的写入以及发送日志调试

This commit is contained in:
2026-03-24 18:02:38 +08:00
parent 9503862eda
commit 97eb3163db
6 changed files with 570 additions and 98 deletions

View File

@@ -7,14 +7,16 @@ import (
"omnisocketgo/cmd/internal/latencylog"
"omnisocketgo/cmd/internal/server"
"omnisocketgo/cmd/internal/transport"
)
func main() {
listenAddr := flag.String("listen", ":9001", "UDP server listen address")
logPath := flag.String("latency-log", "", "optional JSONL file path for latency timestamp logs")
txTimestampDebugLogPath := flag.String("tx-ts-debug-log", "", "optional JSONL file path for TX errqueue debug records")
flag.Parse()
hubOptions := make([]server.UDPOption, 0, 1)
hubOptions := make([]server.UDPOption, 0, 2)
if *logPath != "" {
logger, err := latencylog.NewJSONLLogger(*logPath)
if err != nil {
@@ -23,6 +25,14 @@ func main() {
defer logger.Close()
hubOptions = append(hubOptions, server.WithUDPLogger(logger))
}
if *txTimestampDebugLogPath != "" {
logger, err := transport.NewJSONLTXTimestampDebugLogger(*txTimestampDebugLogPath)
if err != nil {
log.Fatalf("create tx timestamp debug logger %s: %v", *txTimestampDebugLogPath, err)
}
defer logger.Close()
hubOptions = append(hubOptions, server.WithUDPTXTimestampDebugLogger(logger))
}
udpAddr, err := net.ResolveUDPAddr("udp", *listenAddr)
if err != nil {