Skip to content

Commit

Permalink
refactor: Remove unused LogPrintf/LogPrint
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed May 22, 2024
1 parent bc0f655 commit d0c52e3
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,15 +733,12 @@ 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
being found or a new outbound connection being made. These log messages
are unconditional, so care must be taken that they can't be used by an
attacker to fill up storage. Note that `LogPrintf(fmt, params...)` is
a deprecated alias for `LogInfo`.
attacker to fill up storage.

- `LogError(fmt, params...)` should be used in place of `LogInfo` for
severe problems that require the node (or a subsystem) to shut down
Expand Down
4 changes: 2 additions & 2 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,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 @@ -250,7 +250,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
4 changes: 0 additions & 4 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ static inline void LogPrintf_(const std::string& logging_function, const std::st
#define LogError(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, __VA_ARGS__)

// Deprecated unconditional logging.
#define LogPrintf(...) LogInfo(__VA_ARGS__)
#define LogPrintfCategory(category, ...) LogPrintLevel_(category, BCLog::Level::Info, __VA_ARGS__)

// Use a macro instead of a function for conditional logging to prevent
Expand All @@ -259,7 +258,4 @@ static inline void LogPrintf_(const std::string& logging_function, const std::st
#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 test/lint/lint-format-strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
'LogInfo,0',
'LogDebug,1',
'LogTrace,1',
'LogDebug,1',
'LogInfo,0',
'LogPrintfCategory,1',
'LogPrintLevel,2',
'printf,0',
Expand Down

0 comments on commit d0c52e3

Please sign in to comment.