diff --git a/c/opendht.cpp b/c/opendht.cpp index 087ba3c8228556e75c3cfb5d01173be193347484..e5150315d59af69e3f6c6650902e9a079fa1746a 100644 --- a/c/opendht.cpp +++ b/c/opendht.cpp @@ -17,7 +17,9 @@ */ #include "opendht_c.h" -#include "opendht.h" + +#include <opendht.h> +#include <opendht/log.h> using ValueSp = std::shared_ptr<dht::Value>; using PrivkeySp = std::shared_ptr<dht::crypto::PrivateKey>; @@ -333,7 +335,12 @@ int dht_runner_run_config(dht_runner* r, in_port_t port, const dht_runner_config config.push_token = conf->push_token ? std::string(conf->push_token) : std::string{}; config.peer_discovery = conf->peer_discovery; config.peer_publish = conf->peer_publish; - runner->run(port, config); + + dht::DhtRunner::Context context; + if (conf->log) { + context.logger = dht::log::getStdLogger(); + } + runner->run(port, config, std::move(context)); } catch(...) { return ENOTCONN; } diff --git a/c/opendht_c.h b/c/opendht_c.h index 4b3bb729285d7b8e47a9a43ae7889c6b8d836029..a29c2102c8dd6deb532e0a2df4e48de5b3467d3a 100644 --- a/c/opendht_c.h +++ b/c/opendht_c.h @@ -147,6 +147,7 @@ struct OPENDHT_PUBLIC dht_runner_config { bool peer_publish; dht_certificate* server_ca; dht_identity client_identity; + bool log; }; typedef struct dht_runner_config dht_runner_config; OPENDHT_C_PUBLIC void dht_runner_config_default(dht_runner_config* config);