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.
This commit is contained in:
3 files changed
+6
-21
No files matched your search
+3
-8
@@ -358,12 +358,8 @@ bool InitHTTPServer()
|
|||||||
|
|
||||||
// Redirect libevent's logging to our own log
|
// Redirect libevent's logging to our own log
|
||||||
event_set_log_callback(&libevent_log_cb);
|
event_set_log_callback(&libevent_log_cb);
|
||||||
// Update libevent's log handling. Returns false if our version of
|
// Update libevent's log handling.
|
||||||
// libevent doesn't support debug logging, in which case we should
|
UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT));
|
||||||
// clear the BCLog::LIBEVENT flag.
|
|
||||||
if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) {
|
|
||||||
LogInstance().DisableCategory(BCLog::LIBEVENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
evthread_use_windows_threads();
|
evthread_use_windows_threads();
|
||||||
@@ -402,13 +398,12 @@ bool InitHTTPServer()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateHTTPServerLogging(bool enable) {
|
void UpdateHTTPServerLogging(bool enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
event_enable_debug_logging(EVENT_DBG_ALL);
|
event_enable_debug_logging(EVENT_DBG_ALL);
|
||||||
} else {
|
} else {
|
||||||
event_enable_debug_logging(EVENT_DBG_NONE);
|
event_enable_debug_logging(EVENT_DBG_NONE);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::thread g_thread_http;
|
static std::thread g_thread_http;
|
||||||
|
|||||||
+2
-3
@@ -31,9 +31,8 @@ void InterruptHTTPServer();
|
|||||||
/** Stop HTTP server */
|
/** Stop HTTP server */
|
||||||
void StopHTTPServer();
|
void StopHTTPServer();
|
||||||
|
|
||||||
/** Change logging level for libevent. Removes BCLog::LIBEVENT from log categories if
|
/** Change logging level for libevent. */
|
||||||
* libevent doesn't support debug logging.*/
|
void UpdateHTTPServerLogging(bool enable);
|
||||||
bool UpdateHTTPServerLogging(bool enable);
|
|
||||||
|
|
||||||
/** Handler for requests to a certain HTTP path */
|
/** Handler for requests to a certain HTTP path */
|
||||||
typedef std::function<bool(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
|
typedef std::function<bool(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
|
||||||
|
|||||||
+1
-10
@@ -646,17 +646,8 @@ static RPCHelpMan logging()
|
|||||||
uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
|
uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
|
||||||
|
|
||||||
// Update libevent logging if BCLog::LIBEVENT has changed.
|
// 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 (changed_log_categories & BCLog::LIBEVENT) {
|
||||||
if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) {
|
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.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
|
|||||||
Reference in new issue
Block a user