File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -384,15 +384,13 @@ bool InitHTTPServer()
384384
385385 // Redirect libevent's logging to our own log
386386 event_set_log_callback (&libevent_log_cb);
387- #if LIBEVENT_VERSION_NUMBER >= 0x02010100
388- // If -debug=libevent, set full libevent debugging.
389- // Otherwise, disable all libevent debugging.
390- if (LogAcceptCategory (BCLog::LIBEVENT)) {
391- event_enable_debug_logging (EVENT_DBG_ALL);
392- } else {
393- event_enable_debug_logging (EVENT_DBG_NONE);
387+ // Update libevent's log handling. Returns false if our version of
388+ // libevent doesn't support debug logging, in which case we should
389+ // clear the BCLog::LIBEVENT flag.
390+ if (!UpdateHTTPServerLogging (logCategories & BCLog::LIBEVENT)) {
391+ logCategories &= ~BCLog::LIBEVENT;
394392 }
395- # endif
393+
396394#ifdef WIN32
397395 evthread_use_windows_threads ();
398396#else
@@ -435,6 +433,20 @@ bool InitHTTPServer()
435433 return true ;
436434}
437435
436+ bool UpdateHTTPServerLogging (bool enable) {
437+ #if LIBEVENT_VERSION_NUMBER >= 0x02010100
438+ if (enable) {
439+ event_enable_debug_logging (EVENT_DBG_ALL);
440+ } else {
441+ event_enable_debug_logging (EVENT_DBG_NONE);
442+ }
443+ return true ;
444+ #else
445+ // Can't update libevent logging if version < 02010100
446+ return false ;
447+ #endif
448+ }
449+
438450std::thread threadHTTP;
439451std::future<bool > threadResult;
440452
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ void InterruptHTTPServer();
3232/* * Stop HTTP server */
3333void StopHTTPServer ();
3434
35+ /* * Change logging level for libevent. Removes BCLog::LIBEVENT from logCategories if
36+ * libevent doesn't support debug logging.*/
37+ bool UpdateHTTPServerLogging (bool enable);
38+
3539/* * Handler for requests to a certain HTTP path */
3640typedef std::function<bool (HTTPRequest* req, const std::string &)> HTTPRequestHandler;
3741/* * Register handler for prefix.
You can’t perform that action at this time.
0 commit comments