libevent: separate log statements per level
What changed, and why it matters
This commit changes how Bitcoin Core prints log messages coming from the libevent networking library. Previously, all libevent messages went through a single logging path that could be rate-limited. Now, debug messages use the debug-only path, while info/warning/error messages use unconditional logging and are prefixed with 'libevent:'. The main effect is a minor behavior change in log formatting and rate-limiting, not a security fix or vulnerability.
No security action required. Treat as routine logging refactor. Reviewers may want to confirm that unconditional libevent info/warning/error messages do not flood logs under high-error conditions, but this is an operational/logging concern rather than a security issue.
Security signals we found
No security-relevant code change identified
Behavior change in logging only
No memory safety, authentication, cryptography, or network protocol changes
Evidence from the diff
The patch refactors libevent_log_cb() in src/httpserver.cpp. It replaces a single LogPrintLevel(BCLog::LIBEVENT, level, …) call with direct calls to LogDebug, LogInfo, LogWarning, and LogError depending on libevent severity. Debug messages keep the LIBEVENT category and are only emitted when debug logging is enabled. Info-and-above messages become unconditional (no category) and gain a ‘libevent:’ prefix. This avoids rate-limiting unconditional log statements when debug logging is enabled and makes libevent messages more uniform with other unconditional logs.
Changed components
src/httpserver.cpplibevent log callbackHTTP server loggingInspect captured patch +4 / −6
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index abfcb455..6cf47eba 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -422,22 +422,20 @@ static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue, int worker_num)
/** libevent event log callback */
static void libevent_log_cb(int severity, const char *msg)
{
- BCLog::Level level;
switch (severity) {
case EVENT_LOG_DEBUG:
- level = BCLog::Level::Debug;
+ LogDebug(BCLog::LIBEVENT, "%s", msg);
break;
case EVENT_LOG_MSG:
- level = BCLog::Level::Info;
+ LogInfo("libevent: %s", msg);
break;
case EVENT_LOG_WARN:
- level = BCLog::Level::Warning;
+ LogWarning("libevent: %s", msg);
break;
default: // EVENT_LOG_ERR and others are mapped to error
- level = BCLog::Level::Error;
+ LogError("libevent: %s", msg);
break;
}
- LogPrintLevel(BCLog::LIBEVENT, level, "%s\n", msg);
}
bool InitHTTPServer(const util::SignalInterrupt& interrupt)
Why this scored 18/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.