From af567d2ba776004d989f722af8c05186743ee7cf Mon Sep 17 00:00:00 2001 From: WeizhongTu Date: Wed, 6 Dec 2023 19:37:50 +0800 Subject: [PATCH] feat: connection add debug log (#1118) --- internal/remote/remote_client.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/remote/remote_client.go b/internal/remote/remote_client.go index 76db1a14..eabfb756 100644 --- a/internal/remote/remote_client.go +++ b/internal/remote/remote_client.go @@ -180,12 +180,20 @@ func (c *remotingClient) receiveResponse(r *tcpConnWrapper) { return } // ignore name server connection read timeout + var isTimeout bool if netErr, ok := err.(net.Error); ok && netErr.Timeout() { - rlog.Debug("conn error, close connection", map[string]interface{}{ + isTimeout = true + } + if !(err == io.EOF || isTimeout) { + rlog.Error("conn error, close connection", map[string]interface{}{ + "remoteAddr": r.RemoteAddr(), + "localAddr": r.LocalAddr(), rlog.LogKeyUnderlayError: err, }) - } else if err != io.EOF { - rlog.Error("conn error, close connection", map[string]interface{}{ + } else { + rlog.Debug("conn error, close connection", map[string]interface{}{ + "remoteAddr": r.RemoteAddr(), + "localAddr": r.LocalAddr(), rlog.LogKeyUnderlayError: err, }) }