Skip to content

Commit e40779a

Browse files
committed
refactor: Remove outdated libevent logging code
The removed code was intended to catch issues with event_enable_debug_logging which was not available prior to libevent 2.1.1. This is not necessary since the minimum libevent version was bumped to 2.1.8.
1 parent 0598f36 commit e40779a

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

src/httpserver.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,8 @@ bool InitHTTPServer()
358358

359359
// Redirect libevent's logging to our own log
360360
event_set_log_callback(&libevent_log_cb);
361-
// Update libevent's log handling. Returns false if our version of
362-
// libevent doesn't support debug logging, in which case we should
363-
// clear the BCLog::LIBEVENT flag.
364-
if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) {
365-
LogInstance().DisableCategory(BCLog::LIBEVENT);
366-
}
361+
// Update libevent's log handling.
362+
UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT));
367363

368364
#ifdef WIN32
369365
evthread_use_windows_threads();
@@ -402,13 +398,12 @@ bool InitHTTPServer()
402398
return true;
403399
}
404400

405-
bool UpdateHTTPServerLogging(bool enable) {
401+
void UpdateHTTPServerLogging(bool enable) {
406402
if (enable) {
407403
event_enable_debug_logging(EVENT_DBG_ALL);
408404
} else {
409405
event_enable_debug_logging(EVENT_DBG_NONE);
410406
}
411-
return true;
412407
}
413408

414409
static std::thread g_thread_http;

src/httpserver.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ void InterruptHTTPServer();
3131
/** Stop HTTP server */
3232
void StopHTTPServer();
3333

34-
/** Change logging level for libevent. Removes BCLog::LIBEVENT from log categories if
35-
* libevent doesn't support debug logging.*/
36-
bool UpdateHTTPServerLogging(bool enable);
34+
/** Change logging level for libevent. */
35+
void UpdateHTTPServerLogging(bool enable);
3736

3837
/** Handler for requests to a certain HTTP path */
3938
typedef std::function<bool(HTTPRequest* req, const std::string &)> HTTPRequestHandler;

src/rpc/misc.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -646,17 +646,8 @@ static RPCHelpMan logging()
646646
uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
647647

648648
// Update libevent logging if BCLog::LIBEVENT has changed.
649-
// If the library version doesn't allow it, UpdateHTTPServerLogging() returns false,
650-
// in which case we should clear the BCLog::LIBEVENT flag.
651-
// Throw an error if the user has explicitly asked to change only the libevent
652-
// flag and it failed.
653649
if (changed_log_categories & BCLog::LIBEVENT) {
654-
if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) {
655-
LogInstance().DisableCategory(BCLog::LIBEVENT);
656-
if (changed_log_categories == BCLog::LIBEVENT) {
657-
throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1.");
658-
}
659-
}
650+
UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT));
660651
}
661652

662653
UniValue result(UniValue::VOBJ);

0 commit comments

Comments
 (0)