From 4f6ab0708c85f3e3da7726f6caecc381c6d21370 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 20 May 2018 13:13:47 +0000 Subject: Add empty logger to DHT bootstrap daemons. These should register a proper logging callback so the messages don't go devnull, but this at least ensures a logger is available. --- other/DHT_bootstrap.c | 6 ++++-- other/bootstrap_daemon/src/tox-bootstrapd.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'other') diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 60298544..6460be9d 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c @@ -30,8 +30,9 @@ #endif #include "../toxcore/DHT.h" -#include "../toxcore/friend_requests.h" #include "../toxcore/LAN_discovery.h" +#include "../toxcore/friend_requests.h" +#include "../toxcore/logger.h" #include "../toxcore/tox.h" #include "../toxcore/util.h" @@ -115,7 +116,8 @@ int main(int argc, char *argv[]) IP ip; ip_init(&ip, ipv6enabled); - DHT *dht = new_DHT(nullptr, new_networking(nullptr, ip, PORT), true); + Logger *logger = logger_new(); + DHT *dht = new_DHT(logger, new_networking(nullptr, ip, PORT), true); Onion *onion = new_onion(dht); Onion_Announce *onion_a = new_onion_announce(dht); diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c index 9f1a2db4..cbf81d92 100644 --- a/other/bootstrap_daemon/src/tox-bootstrapd.c +++ b/other/bootstrap_daemon/src/tox-bootstrapd.c @@ -37,6 +37,7 @@ #include "../../../toxcore/tox.h" #include "../../../toxcore/LAN_discovery.h" #include "../../../toxcore/TCP_server.h" +#include "../../../toxcore/logger.h" #include "../../../toxcore/onion_announce.h" #include "../../../toxcore/util.h" @@ -245,10 +246,12 @@ int main(int argc, char *argv[]) } } - DHT *dht = new_DHT(nullptr, net, true); + Logger *logger = logger_new(); + DHT *dht = new_DHT(logger, net, true); if (dht == nullptr) { log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox DHT instance. Exiting.\n"); + logger_kill(logger); return 1; } @@ -257,6 +260,7 @@ int main(int argc, char *argv[]) if (!(onion && onion_a)) { log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox Onion. Exiting.\n"); + logger_kill(logger); return 1; } @@ -265,6 +269,7 @@ int main(int argc, char *argv[]) log_write(LOG_LEVEL_INFO, "Set MOTD successfully.\n"); } else { log_write(LOG_LEVEL_ERROR, "Couldn't set MOTD: %s. Exiting.\n", motd); + logger_kill(logger); return 1; } @@ -275,6 +280,7 @@ int main(int argc, char *argv[]) log_write(LOG_LEVEL_INFO, "Keys are managed successfully.\n"); } else { log_write(LOG_LEVEL_ERROR, "Couldn't read/write: %s. Exiting.\n", keys_file_path); + logger_kill(logger); return 1; } @@ -285,6 +291,7 @@ int main(int argc, char *argv[]) if (enable_tcp_relay) { if (tcp_relay_port_count == 0) { log_write(LOG_LEVEL_ERROR, "No TCP relay ports read. Exiting.\n"); + logger_kill(logger); return 1; } @@ -297,6 +304,7 @@ int main(int argc, char *argv[]) log_write(LOG_LEVEL_INFO, "Initialized Tox TCP server successfully.\n"); } else { log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox TCP server. Exiting.\n"); + logger_kill(logger); return 1; } } @@ -305,6 +313,7 @@ int main(int argc, char *argv[]) log_write(LOG_LEVEL_INFO, "List of bootstrap nodes read successfully.\n"); } else { log_write(LOG_LEVEL_ERROR, "Couldn't read list of bootstrap nodes in %s. Exiting.\n", cfg_file_path); + logger_kill(logger); return 1; } -- cgit v1.2.3