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()
384
384
385
385
// Redirect libevent's logging to our own log
386
386
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;
394
392
}
395
- # endif
393
+
396
394
#ifdef WIN32
397
395
evthread_use_windows_threads ();
398
396
#else
@@ -435,6 +433,20 @@ bool InitHTTPServer()
435
433
return true ;
436
434
}
437
435
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
+
438
450
std::thread threadHTTP;
439
451
std::future<bool > threadResult;
440
452
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ void InterruptHTTPServer();
32
32
/* * Stop HTTP server */
33
33
void StopHTTPServer ();
34
34
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
+
35
39
/* * Handler for requests to a certain HTTP path */
36
40
typedef std::function<bool (HTTPRequest* req, const std::string &)> HTTPRequestHandler;
37
41
/* * Register handler for prefix.
You can’t perform that action at this time.
0 commit comments