mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-06 13:47:56 +02:00
scripted-diff: LogPrintLevel(*,BCLog::Level::*,*) -> LogError()/LogWarning()
This is a minimal behavior change and changes log output from: [net:error] Something bad happened [net:warning] Something problematic happened to either [error] Something bad happened [warning] Something problematic happened or, when -loglevelalways=1 is enabled: [all:error] Something bad happened [all:warning] Something problematic happened Such a behavior change is desired, because all warning and error logs are written in the same style in the source code and they are logged in the same format for log consumers. -BEGIN VERIFY SCRIPT- sed --regexp-extended --in-place \ 's/LogPrintLevel\((BCLog::[^,]*), BCLog::Level::(Error|Warning), */Log\2(/g' \ $( git grep -l LogPrintLevel ':(exclude)src/test/logging_tests.cpp' ) -END VERIFY SCRIPT-
This commit is contained in:
@@ -73,7 +73,7 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
|
||||
// Create a netlink socket.
|
||||
auto sock{CreateSock(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)};
|
||||
if (!sock) {
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "socket(AF_NETLINK): %s\n", NetworkErrorString(errno));
|
||||
LogError("socket(AF_NETLINK): %s\n", NetworkErrorString(errno));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
|
||||
request.dst_hdr.nla_len = sizeof(nlattr) + dst_data_len;
|
||||
|
||||
if (sock->Send(&request, request.hdr.nlmsg_len, 0) != static_cast<ssize_t>(request.hdr.nlmsg_len)) {
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "send() to netlink socket: %s\n", NetworkErrorString(errno));
|
||||
LogError("send() to netlink socket: %s\n", NetworkErrorString(errno));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -124,13 +124,13 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
|
||||
recv_result = sock->Recv(response, sizeof(response), 0);
|
||||
} while (recv_result < 0 && (errno == EINTR || errno == EAGAIN));
|
||||
if (recv_result < 0) {
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "recv() from netlink socket: %s\n", NetworkErrorString(errno));
|
||||
LogError("recv() from netlink socket: %s\n", NetworkErrorString(errno));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
total_bytes_read += recv_result;
|
||||
if (total_bytes_read > NETLINK_MAX_RESPONSE_SIZE) {
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "Netlink response exceeded size limit (%zu bytes, family=%d)\n", NETLINK_MAX_RESPONSE_SIZE, family);
|
||||
LogWarning("Netlink response exceeded size limit (%zu bytes, family=%d)\n", NETLINK_MAX_RESPONSE_SIZE, family);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
|
||||
destination_address.si_family = family;
|
||||
status = GetBestInterfaceEx((sockaddr*)&destination_address, &best_if_idx);
|
||||
if (status != NO_ERROR) {
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "Could not get best interface for default route: %s\n", NetworkErrorString(status));
|
||||
LogError("Could not get best interface for default route: %s\n", NetworkErrorString(status));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
|
||||
// Leave interface_luid at all-zeros to use interface index instead.
|
||||
status = GetBestRoute2(&interface_luid, best_if_idx, nullptr, &destination_address, 0, &best_route, &best_source_address);
|
||||
if (status != NO_ERROR) {
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "Could not get best route for default route for interface index %d: %s\n",
|
||||
LogError("Could not get best route for default route for interface index %d: %s\n",
|
||||
best_if_idx, NetworkErrorString(status));
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -235,12 +235,12 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
|
||||
// The size of the available data is determined by calling sysctl() with oldp=nullptr. See sysctl(3).
|
||||
size_t l = 0;
|
||||
if (sysctl(/*name=*/mib, /*namelen=*/sizeof(mib) / sizeof(int), /*oldp=*/nullptr, /*oldlenp=*/&l, /*newp=*/nullptr, /*newlen=*/0) < 0) {
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "Could not get sysctl length of routing table: %s\n", SysErrorString(errno));
|
||||
LogError("Could not get sysctl length of routing table: %s\n", SysErrorString(errno));
|
||||
return std::nullopt;
|
||||
}
|
||||
std::vector<std::byte> buf(l);
|
||||
if (sysctl(/*name=*/mib, /*namelen=*/sizeof(mib) / sizeof(int), /*oldp=*/buf.data(), /*oldlenp=*/&l, /*newp=*/nullptr, /*newlen=*/0) < 0) {
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "Could not get sysctl data of routing table: %s\n", SysErrorString(errno));
|
||||
LogError("Could not get sysctl data of routing table: %s\n", SysErrorString(errno));
|
||||
return std::nullopt;
|
||||
}
|
||||
// Iterate over messages (each message is a routing table entry).
|
||||
@@ -340,7 +340,7 @@ std::vector<CNetAddr> GetLocalAddresses()
|
||||
if (status != NO_ERROR) {
|
||||
// This includes ERROR_NO_DATA if there are no addresses and thus there's not even one PIP_ADAPTER_ADDRESSES
|
||||
// record in the returned structure.
|
||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "Could not get local adapter addresses: %s\n", NetworkErrorString(status));
|
||||
LogError("Could not get local adapter addresses: %s\n", NetworkErrorString(status));
|
||||
return addresses;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user