Skip to content

Commit e1f8dce

Browse files
committed
Merge #13394: cli: Ignore libevent warnings
0231ef6 cli: Ignore libevent warnings (Cory Fields) Pull request description: Should fix rpc tests that fail due to an unclean stderr. Untested as I'm not seeing these warnings. @promag mind seeing if this fixes your problem? Tree-SHA512: fba5ae3f239b515e93e19f9c3eca659eb7fb21f1b1fec25b68285695bfd1ecbdcd9b2235543689aaf97bff85cbb762840f65365a67e791314e9a6b8db2c9e246
2 parents 5779dc4 + 0231ef6 commit e1f8dce

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)