From fa09cb41f58d0483ffe134eb274b9048c5260faa Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 8 Aug 2024 10:56:58 +0200 Subject: refactor: Remove unused LogPrint --- doc/developer-notes.md | 2 -- doc/fuzzing.md | 4 ++-- src/bench/logging.cpp | 10 +++++----- src/logging.h | 3 --- src/test/logging_tests.cpp | 2 -- test/lint/lint-format-strings.py | 1 - 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 99c263bed5..33ab2c72f3 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -741,8 +741,6 @@ logging messages. They should be used as follows: useful for debugging and can reasonably be enabled on a production system (that has sufficient free storage space). They will be logged 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 messages or for infrequent and important events such as a new block tip diff --git a/doc/fuzzing.md b/doc/fuzzing.md index ffc6a04964..4da9f5c3a2 100644 --- a/doc/fuzzing.md +++ b/doc/fuzzing.md @@ -257,7 +257,7 @@ index 7601a6ea84..702d0f56ce 100644 // Check start string, network magic - 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 - 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; } @@ -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 - if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { + 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, HexStr(Span{hash}.first(CMessageHeader::CHECKSUM_SIZE)), EOF diff --git a/src/bench/logging.cpp b/src/bench/logging.cpp index 62c7625fcb..86891af8fe 100644 --- a/src/bench/logging.cpp +++ b/src/bench/logging.cpp @@ -11,7 +11,7 @@ // 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. @@ -40,12 +40,12 @@ static void LogPrintLevelWithoutThreadNames(benchmark::Bench& bench) 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"); }); } -static void LogPrintWithoutCategory(benchmark::Bench& bench) +static void LogWithoutDebug(benchmark::Bench& bench) { 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(LogPrintLevelWithoutThreadNames, benchmark::PriorityLevel::HIGH); -BENCHMARK(LogPrintWithCategory, benchmark::PriorityLevel::HIGH); -BENCHMARK(LogPrintWithoutCategory, benchmark::PriorityLevel::HIGH); +BENCHMARK(LogWithDebug, benchmark::PriorityLevel::HIGH); +BENCHMARK(LogWithoutDebug, benchmark::PriorityLevel::HIGH); BENCHMARK(LogPrintfCategoryWithThreadNames, benchmark::PriorityLevel::HIGH); BENCHMARK(LogPrintfCategoryWithoutThreadNames, benchmark::PriorityLevel::HIGH); BENCHMARK(LogPrintfWithThreadNames, benchmark::PriorityLevel::HIGH); diff --git a/src/logging.h b/src/logging.h index 2ff58979cb..c522cdf348 100644 --- a/src/logging.h +++ b/src/logging.h @@ -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 LogTrace(category, ...) LogPrintLevel(category, BCLog::Level::Trace, __VA_ARGS__) -// Deprecated conditional logging -#define LogPrint(category, ...) LogDebug(category, __VA_ARGS__) - #endif // BITCOIN_LOGGING_H diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp index 8bac988dc2..fdac760d7f 100644 --- a/src/test/logging_tests.cpp +++ b/src/test/logging_tests.cpp @@ -111,7 +111,6 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintf_, LogSetup) BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacrosDeprecated, LogSetup) { 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::Debug, "foo7: %s\n", "bar7"); LogPrintLevel(BCLog::NET, BCLog::Level::Info, "foo8: %s\n", "bar8"); @@ -125,7 +124,6 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacrosDeprecated, LogSetup) } std::vector expected = { "foo5: bar5", - "[net] foo6: bar6", "[net] foo7: bar7", "[net:info] foo8: bar8", "[net:warning] foo9: bar9", diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py index 709a1e7a0e..002c59e9a3 100755 --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -25,7 +25,6 @@ FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS = [ 'LogInfo,0', 'LogDebug,1', 'LogTrace,1', - 'LogDebug,1', 'LogPrintf,0', 'LogPrintfCategory,1', 'LogPrintLevel,2', -- cgit v1.2.3