Skip to content

Commit 0231ef6

Browse files
committed
cli: Ignore libevent warnings
1 parent 0de7cc8 commit 0231ef6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/bitcoin-cli.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ static void SetupCliArgs()
5656
gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN);
5757
}
5858

59+
/** libevent event log callback */
60+
static void libevent_log_cb(int severity, const char *msg)
61+
{
62+
#ifndef EVENT_LOG_ERR // EVENT_LOG_ERR was added in 2.0.19; but before then _EVENT_LOG_ERR existed.
63+
# define EVENT_LOG_ERR _EVENT_LOG_ERR
64+
#endif
65+
// Ignore everything other than errors
66+
if (severity >= EVENT_LOG_ERR) {
67+
throw std::runtime_error(strprintf("libevent error: %s", msg));
68+
}
69+
}
70+
5971
//////////////////////////////////////////////////////////////////////////////
6072
//
6173
// Start
@@ -506,6 +518,7 @@ int main(int argc, char* argv[])
506518
fprintf(stderr, "Error: Initializing networking failed\n");
507519
return EXIT_FAILURE;
508520
}
521+
event_set_log_callback(&libevent_log_cb);
509522

510523
try {
511524
int ret = AppInitRPC(argc, argv);

0 commit comments

Comments
 (0)