Skip to content

Commit

Permalink
refactor: Remove unused LogPrint
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Aug 29, 2024
1 parent 3333415 commit fa09cb4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 15 deletions.
2 changes: 0 additions & 2 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/bench/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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"); });
}
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/test/logging_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -125,7 +124,6 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacrosDeprecated, LogSetup)
}
std::vector<std::string> expected = {
"foo5: bar5",
"[net] foo6: bar6",
"[net] foo7: bar7",
"[net:info] foo8: bar8",
"[net:warning] foo9: bar9",
Expand Down
1 change: 0 additions & 1 deletion test/lint/lint-format-strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
'LogInfo,0',
'LogDebug,1',
'LogTrace,1',
'LogDebug,1',
'LogPrintf,0',
'LogPrintfCategory,1',
'LogPrintLevel,2',
Expand Down

0 comments on commit fa09cb4

Please sign in to comment.