From 18ec120bb9e1fc9d27d2419da4c580bd3cde7e86 Mon Sep 17 00:00:00 2001 From: laanwj <126646+laanwj@users.noreply.github.com> Date: Tue, 24 May 2022 19:54:47 +0200 Subject: [PATCH] http: Use severity-based logging for messages from libevent Map libevent's severity to our own severity level for logging. --- src/httpserver.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index b9a1fc672a3..c463b1b8ab9 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -344,10 +344,22 @@ static void HTTPWorkQueueRun(WorkQueue* queue, int worker_num) /** libevent event log callback */ static void libevent_log_cb(int severity, const char *msg) { - if (severity >= EVENT_LOG_WARN) // Log warn messages and higher without debug category - LogPrintf("libevent: %s\n", msg); - else - LogPrint(BCLog::LIBEVENT, "libevent: %s\n", msg); + BCLog::Level level; + switch (severity) { + case EVENT_LOG_DEBUG: + level = BCLog::Level::Debug; + break; + case EVENT_LOG_MSG: + level = BCLog::Level::Info; + break; + case EVENT_LOG_WARN: + level = BCLog::Level::Warning; + break; + default: // EVENT_LOG_ERR and others are mapped to error + level = BCLog::Level::Error; + break; + } + LogPrintLevel(level, BCLog::LIBEVENT, "%s\n", msg); } bool InitHTTPServer()