scripted-diff: LogPrintLevel(*,BCLog::Level::Debug,*) -> LogDebug()
What changed, and why it matters
This commit is a purely mechanical code cleanup: it replaces a longer logging command with a shorter equivalent one wherever the log level is 'Debug'. The commit message explicitly says it does not change behavior, and the diff shows only one-to-one replacements with no logic changes.
No security action needed. This is a benign refactor; standard code-review approval is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
A scripted diff refactors all calls of the form LogPrintLevel(
Changed components
src/common/pcp.cppsrc/i2p.cppsrc/mapport.cppsrc/net.cppsrc/netbase.cppsrc/node/txreconciliation.cppInspect captured patch +28 / −28
diff --git a/src/common/pcp.cpp b/src/common/pcp.cpp
index 6112dbf5..b2e3ec7e 100644
--- a/src/common/pcp.cpp
+++ b/src/common/pcp.cpp
@@ -228,11 +228,11 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
int recvsz = 0;
for (int ntry = 0; !got_response && ntry < num_tries; ++ntry) {
if (ntry > 0) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Retrying (%d)\n", protocol, ntry);
+ LogDebug(BCLog::NET, "%s: Retrying (%d)\n", protocol, ntry);
}
// Dispatch packet to gateway.
if (sock.Send(request.data(), request.size(), 0) != static_cast<ssize_t>(request.size())) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Could not send request: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
+ LogDebug(BCLog::NET, "%s: Could not send request: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
return std::nullopt; // Network-level error, probably no use retrying.
}
@@ -247,17 +247,17 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
return std::nullopt; // Network-level error, probably no use retrying.
}
if (!occurred) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Timeout\n", protocol);
+ LogDebug(BCLog::NET, "%s: Timeout\n", protocol);
break; // Retry.
}
// Receive response.
recvsz = sock.Recv(response, sizeof(response), MSG_DONTWAIT);
if (recvsz < 0) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Could not receive response: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
+ LogDebug(BCLog::NET, "%s: Could not receive response: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
return std::nullopt; // Network-level error, probably no use retrying.
}
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Received response of %d bytes: %s\n", protocol, recvsz, HexStr(std::span(response, recvsz)));
+ LogDebug(BCLog::NET, "%s: Received response of %d bytes: %s\n", protocol, recvsz, HexStr(std::span(response, recvsz)));
if (check_packet(std::span<uint8_t>(response, recvsz))) {
got_response = true; // Got expected response, break from receive loop as well as from retry loop.
@@ -266,7 +266,7 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
}
}
if (!got_response) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Giving up after %d tries\n", protocol, num_tries);
+ LogDebug(BCLog::NET, "%s: Giving up after %d tries\n", protocol, num_tries);
return std::nullopt;
}
return std::vector<uint8_t>(response, response + recvsz);
@@ -279,7 +279,7 @@ std::variant<MappingResult, MappingError> NATPMPRequestPortMap(const CNetAddr &g
struct sockaddr_storage dest_addr;
socklen_t dest_addrlen = sizeof(struct sockaddr_storage);
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "natpmp: Requesting port mapping port %d from gateway %s\n", port, gateway.ToStringAddr());
+ LogDebug(BCLog::NET, "natpmp: Requesting port mapping port %d from gateway %s\n", port, gateway.ToStringAddr());
// Validate gateway, make sure it's IPv4. NAT-PMP does not support IPv6.
if (!CService(gateway, PCP_SERVER_PORT).GetSockAddr((struct sockaddr*)&dest_addr, &dest_addrlen)) return MappingError::NETWORK_ERROR;
@@ -394,7 +394,7 @@ std::variant<MappingResult, MappingError> PCPRequestPortMap(const PCPMappingNonc
struct sockaddr_storage dest_addr, bind_addr;
socklen_t dest_addrlen = sizeof(struct sockaddr_storage), bind_addrlen = sizeof(struct sockaddr_storage);
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "pcp: Requesting port mapping for addr %s port %d from gateway %s\n", bind.ToStringAddr(), port, gateway.ToStringAddr());
+ LogDebug(BCLog::NET, "pcp: Requesting port mapping for addr %s port %d from gateway %s\n", bind.ToStringAddr(), port, gateway.ToStringAddr());
// Validate addresses, make sure they're the same network family.
if (!CService(gateway, PCP_SERVER_PORT).GetSockAddr((struct sockaddr*)&dest_addr, &dest_addrlen)) return MappingError::NETWORK_ERROR;
@@ -432,7 +432,7 @@ std::variant<MappingResult, MappingError> PCPRequestPortMap(const PCPMappingNonc
}
CService internal;
if (!internal.SetSockAddr((struct sockaddr*)&internal_addr, internal_addrlen)) return MappingError::NETWORK_ERROR;
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "pcp: Internal address after connect: %s\n", internal.ToStringAddr());
+ LogDebug(BCLog::NET, "pcp: Internal address after connect: %s\n", internal.ToStringAddr());
// Build request packet. Make sure the packet is zeroed so that reserved fields are zero
// as required by the spec (and not potentially leak data).
diff --git a/src/i2p.cpp b/src/i2p.cpp
index 80f3bde4..ac7670ea 100644
--- a/src/i2p.cpp
+++ b/src/i2p.cpp
@@ -206,9 +206,9 @@ bool Session::Accept(Connection& conn)
}
if (m_interrupt->interrupted()) {
- LogPrintLevel(BCLog::I2P, BCLog::Level::Debug, "Accept was interrupted\n");
+ LogDebug(BCLog::I2P, "Accept was interrupted\n");
} else {
- LogPrintLevel(BCLog::I2P, BCLog::Level::Debug, "Error accepting%s: %s\n", disconnect ? " (will close the session)" : "", errmsg);
+ LogDebug(BCLog::I2P, "Error accepting%s: %s\n", disconnect ? " (will close the session)" : "", errmsg);
}
if (disconnect) {
LOCK(m_mutex);
@@ -224,7 +224,7 @@ bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error)
// Refuse connecting to arbitrary ports. We don't specify any destination port to the SAM proxy
// when connecting (SAM 3.1 does not use ports) and it forces/defaults it to I2P_SAM31_PORT.
if (to.GetPort() != I2P_SAM31_PORT) {
- LogPrintLevel(BCLog::I2P, BCLog::Level::Debug, "Error connecting to %s, connection refused due to arbitrary port %s\n", to.ToStringAddrPort(), to.GetPort());
+ LogDebug(BCLog::I2P, "Error connecting to %s, connection refused due to arbitrary port %s\n", to.ToStringAddrPort(), to.GetPort());
proxy_error = false;
return false;
}
@@ -272,7 +272,7 @@ bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error)
throw std::runtime_error(strprintf("\"%s\"", connect_reply.full));
} catch (const std::runtime_error& e) {
- LogPrintLevel(BCLog::I2P, BCLog::Level::Debug, "Error connecting to %s: %s\n", to.ToStringAddrPort(), e.what());
+ LogDebug(BCLog::I2P, "Error connecting to %s: %s\n", to.ToStringAddrPort(), e.what());
CheckControlSock();
return false;
}
@@ -345,7 +345,7 @@ void Session::CheckControlSock()
std::string errmsg;
if (m_control_sock && !m_control_sock->IsConnected(errmsg)) {
- LogPrintLevel(BCLog::I2P, BCLog::Level::Debug, "Control socket error: %s\n", errmsg);
+ LogDebug(BCLog::I2P, "Control socket error: %s\n", errmsg);
Disconnect();
}
}
@@ -415,7 +415,7 @@ void Session::CreateIfNotCreatedAlready()
const auto session_type = m_transient ? "transient" : "persistent";
const auto session_id = GetRandHash().GetHex().substr(0, 10); // full is overkill, too verbose in the logs
- LogPrintLevel(BCLog::I2P, BCLog::Level::Debug, "Creating %s SAM session %s with %s\n", session_type, session_id, m_control_host.ToString());
+ LogDebug(BCLog::I2P, "Creating %s SAM session %s with %s\n", session_type, session_id, m_control_host.ToString());
auto sock = Hello();
diff --git a/src/mapport.cpp b/src/mapport.cpp
index 976572c5..f6df4fb5 100644
--- a/src/mapport.cpp
+++ b/src/mapport.cpp
@@ -67,9 +67,9 @@ static void ProcessPCP()
// IPv4
std::optional<CNetAddr> gateway4 = QueryDefaultGateway(NET_IPV4);
if (!gateway4) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "portmap: Could not determine IPv4 default gateway\n");
+ LogDebug(BCLog::NET, "portmap: Could not determine IPv4 default gateway\n");
} else {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "portmap: gateway [IPv4]: %s\n", gateway4->ToStringAddr());
+ LogDebug(BCLog::NET, "portmap: gateway [IPv4]: %s\n", gateway4->ToStringAddr());
// Open a port mapping on whatever local address we have toward the gateway.
struct in_addr inaddr_any;
@@ -77,7 +77,7 @@ static void ProcessPCP()
auto res = PCPRequestPortMap(pcp_nonce, *gateway4, CNetAddr(inaddr_any), private_port, requested_lifetime, g_mapport_interrupt);
MappingError* pcp_err = std::get_if<MappingError>(&res);
if (pcp_err && *pcp_err == MappingError::UNSUPP_VERSION) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "portmap: Got unsupported PCP version response, falling back to NAT-PMP\n");
+ LogDebug(BCLog::NET, "portmap: Got unsupported PCP version response, falling back to NAT-PMP\n");
res = NATPMPRequestPortMap(*gateway4, private_port, requested_lifetime, g_mapport_interrupt);
}
handle_mapping(res);
@@ -86,9 +86,9 @@ static void ProcessPCP()
// IPv6
std::optional<CNetAddr> gateway6 = QueryDefaultGateway(NET_IPV6);
if (!gateway6) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "portmap: Could not determine IPv6 default gateway\n");
+ LogDebug(BCLog::NET, "portmap: Could not determine IPv6 default gateway\n");
} else {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "portmap: gateway [IPv6]: %s\n", gateway6->ToStringAddr());
+ LogDebug(BCLog::NET, "portmap: gateway [IPv6]: %s\n", gateway6->ToStringAddr());
// Try to open pinholes for all routable local IPv6 addresses.
for (const auto &addr: GetLocalAddresses()) {
diff --git a/src/net.cpp b/src/net.cpp
index dc21017f..771b1a36 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -395,7 +395,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect,
}
}
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "trying %s connection %s lastseen=%.1fhrs\n",
+ LogDebug(BCLog::NET, "trying %s connection %s lastseen=%.1fhrs\n",
use_v2transport ? "v2" : "v1",
pszDest ? pszDest : addrConnect.ToStringAddrPort(),
Ticks<HoursDouble>(pszDest ? 0h : Now<NodeSeconds>() - addrConnect.nTime));
@@ -485,7 +485,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect,
addr_bind = conn.me;
}
} else if (use_proxy) {
- LogPrintLevel(BCLog::PROXY, BCLog::Level::Debug, "Using proxy: %s to connect to %s\n", proxy.ToString(), target_addr.ToStringAddrPort());
+ LogDebug(BCLog::PROXY, "Using proxy: %s to connect to %s\n", proxy.ToString(), target_addr.ToStringAddrPort());
sock = ConnectThroughProxy(proxy, target_addr.ToStringAddr(), target_addr.GetPort(), proxyConnectionFailed);
} else {
// no proxy needed (none set for target network)
@@ -2857,7 +2857,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect, std
// not use our limited outbound slots for them and to ensure
// addnode connections benefit from their intended protections.
if (AddedNodesContain(addr)) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "Not making automatic %s%s connection to %s peer selected for manual (addnode) connection%s\n",
+ LogDebug(BCLog::NET, "Not making automatic %s%s connection to %s peer selected for manual (addnode) connection%s\n",
preferred_net.has_value() ? "network-specific " : "",
ConnectionTypeAsString(conn_type), GetNetworkName(addr.GetNetwork()),
fLogIPs ? strprintf(": %s", addr.ToStringAddrPort()) : "");
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 5d8ec5ee..4d2512ee 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -480,7 +480,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
}
if (pchRet2[1] != SOCKS5Reply::SUCCEEDED) {
// Failures to connect to a peer that are not proxy errors
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug,
+ LogDebug(BCLog::NET,
"Socks5() connect to %s:%d failed: %s\n", strDest, port, Socks5ErrorString(pchRet2[1]));
return false;
}
@@ -610,7 +610,7 @@ static bool ConnectToSocket(const Sock& sock, struct sockaddr* sockaddr, socklen
NetworkErrorString(WSAGetLastError()));
return false;
} else if (occurred == 0) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "connection attempt to %s timed out\n", dest_str);
+ LogDebug(BCLog::NET, "connection attempt to %s timed out\n", dest_str);
return false;
}
diff --git a/src/node/txreconciliation.cpp b/src/node/txreconciliation.cpp
index e6e19c57..73f76693 100644
--- a/src/node/txreconciliation.cpp
+++ b/src/node/txreconciliation.cpp
@@ -84,7 +84,7 @@ public:
AssertLockNotHeld(m_txreconciliation_mutex);
LOCK(m_txreconciliation_mutex);
- LogPrintLevel(BCLog::TXRECONCILIATION, BCLog::Level::Debug, "Pre-register peer=%d\n", peer_id);
+ LogDebug(BCLog::TXRECONCILIATION, "Pre-register peer=%d\n", peer_id);
const uint64_t local_salt{FastRandomContext().rand64()};
// We do this exactly once per peer (which are unique by NodeId, see GetNewNodeId) so it's
@@ -117,7 +117,7 @@ public:
// v1 is the lowest version, so suggesting something below must be a protocol violation.
if (recon_version < 1) return ReconciliationRegisterResult::PROTOCOL_VIOLATION;
- LogPrintLevel(BCLog::TXRECONCILIATION, BCLog::Level::Debug, "Register peer=%d (inbound=%i)\n",
+ LogDebug(BCLog::TXRECONCILIATION, "Register peer=%d (inbound=%i)\n",
peer_id, is_peer_inbound);
const uint256 full_salt{ComputeSalt(local_salt, remote_salt)};
@@ -130,7 +130,7 @@ public:
AssertLockNotHeld(m_txreconciliation_mutex);
LOCK(m_txreconciliation_mutex);
if (m_states.erase(peer_id)) {
- LogPrintLevel(BCLog::TXRECONCILIATION, BCLog::Level::Debug, "Forget txreconciliation state of peer=%d\n", peer_id);
+ LogDebug(BCLog::TXRECONCILIATION, "Forget txreconciliation state of peer=%d\n", peer_id);
}
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.