Skip to content

Commit f7edea3

Browse files
committed
net: make debug logging conditional on -debug=net
1 parent a410ae8 commit f7edea3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/net.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ size_t CConnman::SocketSendData(CNode& node) const
815815
// error
816816
int nErr = WSAGetLastError();
817817
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) {
818-
LogPrintf("socket send error %s\n", NetworkErrorString(nErr));
818+
LogPrint(BCLog::NET, "socket send error for peer=%d: %s\n", node.GetId(), NetworkErrorString(nErr));
819819
node.CloseSocketDisconnect();
820820
}
821821
}
@@ -1053,7 +1053,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
10531053
}
10541054

10551055
if (!fNetworkActive) {
1056-
LogPrintf("connection from %s dropped: not accepting new connections\n", addr.ToString());
1056+
LogPrint(BCLog::NET, "connection from %s dropped: not accepting new connections\n", addr.ToString());
10571057
CloseSocket(hSocket);
10581058
return;
10591059
}
@@ -1236,20 +1236,20 @@ bool CConnman::InactivityCheck(const CNode& node) const
12361236
}
12371237

12381238
if (now > node.nLastSend + TIMEOUT_INTERVAL) {
1239-
LogPrintf("socket sending timeout: %is\n", now - node.nLastSend);
1239+
LogPrint(BCLog::NET, "socket sending timeout: %is peer=%d\n", now - node.nLastSend, node.GetId());
12401240
return true;
12411241
}
12421242

12431243
if (now > node.nLastRecv + TIMEOUT_INTERVAL) {
1244-
LogPrintf("socket receive timeout: %is\n", now - node.nLastRecv);
1244+
LogPrint(BCLog::NET, "socket receive timeout: %is peer=%d\n", now - node.nLastRecv, node.GetId());
12451245
return true;
12461246
}
12471247

12481248
if (node.nPingNonceSent && node.m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL} < GetTime<std::chrono::microseconds>()) {
12491249
// We use mockable time for ping timeouts. This means that setmocktime
12501250
// may cause pings to time out for peers that have been connected for
12511251
// longer than m_peer_connect_timeout.
1252-
LogPrintf("ping timeout: %fs\n", 0.000001 * count_microseconds(GetTime<std::chrono::microseconds>() - node.m_ping_start.load()));
1252+
LogPrint(BCLog::NET, "ping timeout: %fs peer=%d\n", 0.000001 * count_microseconds(GetTime<std::chrono::microseconds>() - node.m_ping_start.load()), node.GetId());
12531253
return true;
12541254
}
12551255

0 commit comments

Comments
 (0)