mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
refactor: Remove unused LogPrint
This commit is contained in:
parent
3333415890
commit
fa09cb41f5
6 changed files with 7 additions and 15 deletions
|
@ -741,8 +741,6 @@ logging messages. They should be used as follows:
|
||||||
useful for debugging and can reasonably be enabled on a production
|
useful for debugging and can reasonably be enabled on a production
|
||||||
system (that has sufficient free storage space). They will be logged
|
system (that has sufficient free storage space). They will be logged
|
||||||
if the program is started with `-debug=category` or `-debug=1`.
|
if the program is started with `-debug=category` or `-debug=1`.
|
||||||
Note that `LogPrint(BCLog::CATEGORY, fmt, params...)` is a deprecated
|
|
||||||
alias for `LogDebug`.
|
|
||||||
|
|
||||||
- `LogInfo(fmt, params...)` should only be used rarely, e.g. for startup
|
- `LogInfo(fmt, params...)` should only be used rarely, e.g. for startup
|
||||||
messages or for infrequent and important events such as a new block tip
|
messages or for infrequent and important events such as a new block tip
|
||||||
|
|
|
@ -257,7 +257,7 @@ index 7601a6ea84..702d0f56ce 100644
|
||||||
// Check start string, network magic
|
// Check start string, network magic
|
||||||
- if (memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
|
- if (memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
|
||||||
+ if (false && memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) { // skip network magic checking
|
+ if (false && memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) { // skip network magic checking
|
||||||
LogPrint(BCLog::NET, "Header error: Wrong MessageStart %s received, peer=%d\n", HexStr(hdr.pchMessageStart), m_node_id);
|
LogDebug(BCLog::NET, "Header error: Wrong MessageStart %s received, peer=%d\n", HexStr(hdr.pchMessageStart), m_node_id);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -788,7 +788,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
|
@@ -788,7 +788,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
|
||||||
|
@ -266,7 +266,7 @@ index 7601a6ea84..702d0f56ce 100644
|
||||||
// Check checksum and header message type string
|
// Check checksum and header message type string
|
||||||
- if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) {
|
- if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) {
|
||||||
+ if (false && memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { // skip checksum checking
|
+ if (false && memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { // skip checksum checking
|
||||||
LogPrint(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n",
|
LogDebug(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n",
|
||||||
SanitizeString(msg.m_type), msg.m_message_size,
|
SanitizeString(msg.m_type), msg.m_message_size,
|
||||||
HexStr(Span{hash}.first(CMessageHeader::CHECKSUM_SIZE)),
|
HexStr(Span{hash}.first(CMessageHeader::CHECKSUM_SIZE)),
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
// All but 2 of the benchmarks should have roughly similar performance:
|
// All but 2 of the benchmarks should have roughly similar performance:
|
||||||
//
|
//
|
||||||
// LogPrintWithoutCategory should be ~3 orders of magnitude faster, as nothing is logged.
|
// LogWithoutDebug should be ~3 orders of magnitude faster, as nothing is logged.
|
||||||
//
|
//
|
||||||
// LogWithoutWriteToFile should be ~2 orders of magnitude faster, as it avoids disk writes.
|
// LogWithoutWriteToFile should be ~2 orders of magnitude faster, as it avoids disk writes.
|
||||||
|
|
||||||
|
@ -40,12 +40,12 @@ static void LogPrintLevelWithoutThreadNames(benchmark::Bench& bench)
|
||||||
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", "test"); });
|
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", "test"); });
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LogPrintWithCategory(benchmark::Bench& bench)
|
static void LogWithDebug(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { LogDebug(BCLog::NET, "%s\n", "test"); });
|
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { LogDebug(BCLog::NET, "%s\n", "test"); });
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LogPrintWithoutCategory(benchmark::Bench& bench)
|
static void LogWithoutDebug(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
Logging(bench, {"-logthreadnames=0", "-debug=0"}, [] { LogDebug(BCLog::NET, "%s\n", "test"); });
|
Logging(bench, {"-logthreadnames=0", "-debug=0"}, [] { LogDebug(BCLog::NET, "%s\n", "test"); });
|
||||||
}
|
}
|
||||||
|
@ -85,8 +85,8 @@ static void LogWithoutWriteToFile(benchmark::Bench& bench)
|
||||||
|
|
||||||
BENCHMARK(LogPrintLevelWithThreadNames, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(LogPrintLevelWithThreadNames, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(LogPrintLevelWithoutThreadNames, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(LogPrintLevelWithoutThreadNames, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(LogPrintWithCategory, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(LogWithDebug, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(LogPrintWithoutCategory, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(LogWithoutDebug, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(LogPrintfCategoryWithThreadNames, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(LogPrintfCategoryWithThreadNames, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(LogPrintfCategoryWithoutThreadNames, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(LogPrintfCategoryWithoutThreadNames, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(LogPrintfWithThreadNames, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(LogPrintfWithThreadNames, benchmark::PriorityLevel::HIGH);
|
||||||
|
|
|
@ -289,7 +289,4 @@ static inline void LogPrintf_(std::string_view logging_function, std::string_vie
|
||||||
#define LogDebug(category, ...) LogPrintLevel(category, BCLog::Level::Debug, __VA_ARGS__)
|
#define LogDebug(category, ...) LogPrintLevel(category, BCLog::Level::Debug, __VA_ARGS__)
|
||||||
#define LogTrace(category, ...) LogPrintLevel(category, BCLog::Level::Trace, __VA_ARGS__)
|
#define LogTrace(category, ...) LogPrintLevel(category, BCLog::Level::Trace, __VA_ARGS__)
|
||||||
|
|
||||||
// Deprecated conditional logging
|
|
||||||
#define LogPrint(category, ...) LogDebug(category, __VA_ARGS__)
|
|
||||||
|
|
||||||
#endif // BITCOIN_LOGGING_H
|
#endif // BITCOIN_LOGGING_H
|
||||||
|
|
|
@ -111,7 +111,6 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintf_, LogSetup)
|
||||||
BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacrosDeprecated, LogSetup)
|
BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacrosDeprecated, LogSetup)
|
||||||
{
|
{
|
||||||
LogPrintf("foo5: %s\n", "bar5");
|
LogPrintf("foo5: %s\n", "bar5");
|
||||||
LogDebug(BCLog::NET, "foo6: %s\n", "bar6");
|
|
||||||
LogPrintLevel(BCLog::NET, BCLog::Level::Trace, "foo4: %s\n", "bar4"); // not logged
|
LogPrintLevel(BCLog::NET, BCLog::Level::Trace, "foo4: %s\n", "bar4"); // not logged
|
||||||
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "foo7: %s\n", "bar7");
|
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "foo7: %s\n", "bar7");
|
||||||
LogPrintLevel(BCLog::NET, BCLog::Level::Info, "foo8: %s\n", "bar8");
|
LogPrintLevel(BCLog::NET, BCLog::Level::Info, "foo8: %s\n", "bar8");
|
||||||
|
@ -125,7 +124,6 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacrosDeprecated, LogSetup)
|
||||||
}
|
}
|
||||||
std::vector<std::string> expected = {
|
std::vector<std::string> expected = {
|
||||||
"foo5: bar5",
|
"foo5: bar5",
|
||||||
"[net] foo6: bar6",
|
|
||||||
"[net] foo7: bar7",
|
"[net] foo7: bar7",
|
||||||
"[net:info] foo8: bar8",
|
"[net:info] foo8: bar8",
|
||||||
"[net:warning] foo9: bar9",
|
"[net:warning] foo9: bar9",
|
||||||
|
|
|
@ -25,7 +25,6 @@ FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS = [
|
||||||
'LogInfo,0',
|
'LogInfo,0',
|
||||||
'LogDebug,1',
|
'LogDebug,1',
|
||||||
'LogTrace,1',
|
'LogTrace,1',
|
||||||
'LogDebug,1',
|
|
||||||
'LogPrintf,0',
|
'LogPrintf,0',
|
||||||
'LogPrintfCategory,1',
|
'LogPrintfCategory,1',
|
||||||
'LogPrintLevel,2',
|
'LogPrintLevel,2',
|
||||||
|
|
Loading…
Add table
Reference in a new issue