ipc: separate log statements per level
What changed, and why it matters
This is a routine logging cleanup in Bitcoin Core's inter-process communication (IPC) code. It changes how messages from the internal IPC library are written to the log file, mainly to prevent a harmless side effect where enabling detailed debug logging could accidentally suppress some log lines. There is no security vulnerability here.
No security action required. Treat as normal code maintenance. Reviewers may want to confirm the new 'ipc:' prefix and category removal are acceptable from a user-support/log-consistency perspective.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors IpcLogFn() in src/ipc/capnp/protocol.cpp. Previously all IPC log messages were routed through LogPrintLevel(BCLog::IPC, …), which applies rate-limiting to unconditional log levels. The patch replaces that with level-specific macros: LogTrace/LogDebug keep the BCLog::IPC category and remain conditional on debug categories, while LogInfo/LogWarning/LogError become unconditional, lose the BCLog::IPC category, and gain an ‘ipc:’ string prefix. The mp::Log::Raise case continues to log at error level and then throw Exception. The removed ConvertIPCLogLevel helper is inlined into the switch. This is a behavior change in logging only, not in trust boundaries, memory handling, or network processing.
Changed components
src/ipc/capnp/protocol.cppIpcLogFn()Bitcoin Core IPC loggingInspect captured patch +24 / −18
diff --git a/src/ipc/capnp/protocol.cpp b/src/ipc/capnp/protocol.cpp
index 27ef73e8..ff93b0a7 100644
--- a/src/ipc/capnp/protocol.cpp
+++ b/src/ipc/capnp/protocol.cpp
@@ -31,22 +31,6 @@ namespace ipc {
namespace capnp {
namespace {
-BCLog::Level ConvertIPCLogLevel(mp::Log level)
-{
- switch (level) {
- case mp::Log::Trace: return BCLog::Level::Trace;
- case mp::Log::Debug: return BCLog::Level::Debug;
- case mp::Log::Info: return BCLog::Level::Info;
- case mp::Log::Warning: return BCLog::Level::Warning;
- case mp::Log::Error: return BCLog::Level::Error;
- case mp::Log::Raise: return BCLog::Level::Error;
- } // no default case, so the compiler can warn about missing cases
-
- // Be conservative and assume that if MP ever adds a new log level, it
- // should only be shown at our most verbose level.
- return BCLog::Level::Trace;
-}
-
mp::Log GetRequestedIPCLogLevel()
{
if (LogAcceptCategory(BCLog::IPC, BCLog::Level::Trace)) return mp::Log::Trace;
@@ -58,8 +42,30 @@ mp::Log GetRequestedIPCLogLevel()
void IpcLogFn(mp::LogMessage message)
{
- LogPrintLevel(BCLog::IPC, ConvertIPCLogLevel(message.level), "%s\n", message.message);
- if (message.level == mp::Log::Raise) throw Exception(message.message);
+ switch (message.level) {
+ case mp::Log::Trace:
+ LogTrace(BCLog::IPC, "%s", message.message);
+ return;
+ case mp::Log::Debug:
+ LogDebug(BCLog::IPC, "%s", message.message);
+ return;
+ case mp::Log::Info:
+ LogInfo("ipc: %s", message.message);
+ return;
+ case mp::Log::Warning:
+ LogWarning("ipc: %s", message.message);
+ return;
+ case mp::Log::Error:
+ LogError("ipc: %s", message.message);
+ return;
+ case mp::Log::Raise:
+ LogError("ipc: %s", message.message);
+ throw Exception(message.message);
+ } // no default case, so the compiler can warn about missing cases
+
+ // Be conservative and assume that if MP ever adds a new log level, it
+ // should only be shown at our most verbose level.
+ LogTrace(BCLog::IPC, "%s", message.message);
}
class CapnpProtocol : public Protocol
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.