From e40779a4fee03c6c455149bd8e9d1a7ccd991450 Mon Sep 17 00:00:00 2001 From: Fabian Jahr Date: Sat, 2 Apr 2022 19:26:46 +0200 Subject: [PATCH] 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. --- src/httpserver.cpp | 11 +++-------- src/httpserver.h | 5 ++--- src/rpc/misc.cpp | 11 +---------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index f1116e35be0..d2b2ea11b8e 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -358,12 +358,8 @@ bool InitHTTPServer() // Redirect libevent's logging to our own log event_set_log_callback(&libevent_log_cb); - // Update libevent's log handling. Returns false if our version of - // libevent doesn't support debug logging, in which case we should - // clear the BCLog::LIBEVENT flag. - if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) { - LogInstance().DisableCategory(BCLog::LIBEVENT); - } + // Update libevent's log handling. + UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT)); #ifdef WIN32 evthread_use_windows_threads(); @@ -402,13 +398,12 @@ bool InitHTTPServer() return true; } -bool UpdateHTTPServerLogging(bool enable) { +void UpdateHTTPServerLogging(bool enable) { if (enable) { event_enable_debug_logging(EVENT_DBG_ALL); } else { event_enable_debug_logging(EVENT_DBG_NONE); } - return true; } static std::thread g_thread_http; diff --git a/src/httpserver.h b/src/httpserver.h index 97cd63778a0..92c8cf1843a 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -31,9 +31,8 @@ void InterruptHTTPServer(); /** Stop HTTP server */ void StopHTTPServer(); -/** Change logging level for libevent. Removes BCLog::LIBEVENT from log categories if - * libevent doesn't support debug logging.*/ -bool UpdateHTTPServerLogging(bool enable); +/** Change logging level for libevent. */ +void UpdateHTTPServerLogging(bool enable); /** Handler for requests to a certain HTTP path */ typedef std::function HTTPRequestHandler; diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 8d7b48d697d..8496e459a6e 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -646,17 +646,8 @@ static RPCHelpMan logging() uint32_t changed_log_categories = original_log_categories ^ updated_log_categories; // Update libevent logging if BCLog::LIBEVENT has changed. - // If the library version doesn't allow it, UpdateHTTPServerLogging() returns false, - // in which case we should clear the BCLog::LIBEVENT flag. - // Throw an error if the user has explicitly asked to change only the libevent - // flag and it failed. if (changed_log_categories & BCLog::LIBEVENT) { - if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) { - LogInstance().DisableCategory(BCLog::LIBEVENT); - if (changed_log_categories == BCLog::LIBEVENT) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1."); - } - } + UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT)); } UniValue result(UniValue::VOBJ);