fix: kcp 协议内部日志细节
This commit is contained in:
@@ -25,10 +25,17 @@ func main() {
|
||||
inboxDir := flag.String("inbox-dir", "inbox", "directory used to persist received text and file messages")
|
||||
logPath := flag.String("latency-log", "", "optional JSONL file path for latency timestamp logs")
|
||||
kcpTimestampDebugLogPath := flag.String("kcp-ts-debug-log", "", "optional JSONL file path for KCP packet kernel timestamp debug records")
|
||||
kcpSessionStatsLogPath := flag.String("kcp-session-stats-log", "", "optional JSONL file path for KCP session stats records")
|
||||
kcpSessionStatsInterval := flag.String("kcp-session-stats-interval", transport.DefaultKCPSessionStatsInterval.String(), "sampling interval for KCP session stats, for example 100ms")
|
||||
interactive := flag.Bool("interactive", true, "enable interactive REPL for repeated text/file sends on the same connection")
|
||||
flag.Parse()
|
||||
|
||||
clientOptions := make([]peerpkg.Option, 0, 5)
|
||||
statsInterval, err := transport.ParseKCPSessionStatsInterval(*kcpSessionStatsInterval)
|
||||
if err != nil {
|
||||
log.Fatalf("parse -kcp-session-stats-interval=%q: %v", *kcpSessionStatsInterval, err)
|
||||
}
|
||||
|
||||
clientOptions := make([]peerpkg.Option, 0, 6)
|
||||
if *logPath != "" {
|
||||
logger, err := latencylog.NewJSONLLogger(*logPath)
|
||||
if err != nil {
|
||||
@@ -45,6 +52,14 @@ func main() {
|
||||
defer logger.Close()
|
||||
clientOptions = append(clientOptions, peerpkg.WithKCPPacketDebugLogger(logger))
|
||||
}
|
||||
if *kcpSessionStatsLogPath != "" {
|
||||
logger, err := transport.NewJSONLKCPSessionStatsLogger(*kcpSessionStatsLogPath)
|
||||
if err != nil {
|
||||
log.Fatalf("create kcp session stats logger %s: %v", *kcpSessionStatsLogPath, err)
|
||||
}
|
||||
defer logger.Close()
|
||||
clientOptions = append(clientOptions, peerpkg.WithKCPSessionStatsLogger(logger, statsInterval))
|
||||
}
|
||||
if *bindIP != "" {
|
||||
clientOptions = append(clientOptions, peerpkg.WithBindIP(*bindIP))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user