diff options
| author | Wladimir J. van der Laan <[email protected]> | 2017-04-12 17:48:58 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-04-12 19:57:22 +0200 |
| commit | 350b22497c7ce8afea8ebf6129571056dfd11a80 (patch) | |
| tree | 7ad3a55dbfd7b49110dd78fea5c647232c50daa8 /src/httpserver.cpp | |
| parent | Merge #10187: tests: Fix test_runner return value in case of skipped test (diff) | |
| parent | allow libevent logging to be updated during runtime (diff) | |
| download | discoin-350b22497c7ce8afea8ebf6129571056dfd11a80.tar.xz discoin-350b22497c7ce8afea8ebf6129571056dfd11a80.zip | |
Merge #10150: [rpc] Add logging rpc
7fd50c3 allow libevent logging to be updated during runtime (John Newbery)
5255aca [rpc] Add logging RPC (John Newbery)
4d9950d Set BCLog::LIBEVENT correctly for old libevent versions. (John Newbery)
Tree-SHA512: d6788a7205372c0528da71eca052910dfb055f2940ca884f422ff3db66e23a2b49c6a15b8f27d5255554fe5c5a928f5dd903fdc63b0bd6c8fa7783e77bb30fe8
Diffstat (limited to 'src/httpserver.cpp')
| -rw-r--r-- | src/httpserver.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 347433eb1..e7df23295 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -384,15 +384,13 @@ bool InitHTTPServer() // Redirect libevent's logging to our own log event_set_log_callback(&libevent_log_cb); -#if LIBEVENT_VERSION_NUMBER >= 0x02010100 - // If -debug=libevent, set full libevent debugging. - // Otherwise, disable all libevent debugging. - if (LogAcceptCategory(BCLog::LIBEVENT)) { - event_enable_debug_logging(EVENT_DBG_ALL); - } else { - event_enable_debug_logging(EVENT_DBG_NONE); + // 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(logCategories & BCLog::LIBEVENT)) { + logCategories &= ~BCLog::LIBEVENT; } -#endif + #ifdef WIN32 evthread_use_windows_threads(); #else @@ -435,6 +433,20 @@ bool InitHTTPServer() return true; } +bool UpdateHTTPServerLogging(bool enable) { +#if LIBEVENT_VERSION_NUMBER >= 0x02010100 + if (enable) { + event_enable_debug_logging(EVENT_DBG_ALL); + } else { + event_enable_debug_logging(EVENT_DBG_NONE); + } + return true; +#else + // Can't update libevent logging if version < 02010100 + return false; +#endif +} + std::thread threadHTTP; std::future<bool> threadResult; |