Skip to content

Commit 18ec120

Browse files
committed
http: Use severity-based logging for messages from libevent
Map libevent's severity to our own severity level for logging.
1 parent bd971bf commit 18ec120

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/httpserver.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,22 @@ static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue, int worker_num)
344344
/** libevent event log callback */
345345
static void libevent_log_cb(int severity, const char *msg)
346346
{
347-
if (severity >= EVENT_LOG_WARN) // Log warn messages and higher without debug category
348-
LogPrintf("libevent: %s\n", msg);
349-
else
350-
LogPrint(BCLog::LIBEVENT, "libevent: %s\n", msg);
347+
BCLog::Level level;
348+
switch (severity) {
349+
case EVENT_LOG_DEBUG:
350+
level = BCLog::Level::Debug;
351+
break;
352+
case EVENT_LOG_MSG:
353+
level = BCLog::Level::Info;
354+
break;
355+
case EVENT_LOG_WARN:
356+
level = BCLog::Level::Warning;
357+
break;
358+
default: // EVENT_LOG_ERR and others are mapped to error
359+
level = BCLog::Level::Error;
360+
break;
361+
}
362+
LogPrintLevel(level, BCLog::LIBEVENT, "%s\n", msg);
351363
}
352364

353365
bool InitHTTPServer()

0 commit comments

Comments
 (0)