diff options
Diffstat (limited to 'other/DHT_bootstrap.c')
-rw-r--r-- | other/DHT_bootstrap.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index ddec0d7b..637cb442 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c | |||
@@ -94,6 +94,40 @@ static void manage_keys(DHT *dht) | |||
94 | fclose(keys_file); | 94 | fclose(keys_file); |
95 | } | 95 | } |
96 | 96 | ||
97 | static void print_log(void *context, Logger_Level level, const char *file, int line, | ||
98 | const char *func, const char *message, void *userdata) | ||
99 | { | ||
100 | char *strlevel; | ||
101 | |||
102 | switch (level) { | ||
103 | case LOGGER_LEVEL_TRACE: | ||
104 | strlevel = "TRACE"; | ||
105 | break; | ||
106 | |||
107 | case LOGGER_LEVEL_DEBUG: | ||
108 | strlevel = "DEBUG"; | ||
109 | break; | ||
110 | |||
111 | case LOGGER_LEVEL_INFO: | ||
112 | strlevel = "INFO"; | ||
113 | break; | ||
114 | |||
115 | case LOGGER_LEVEL_WARNING: | ||
116 | strlevel = "WARNING"; | ||
117 | break; | ||
118 | |||
119 | case LOGGER_LEVEL_ERROR: | ||
120 | strlevel = "ERROR"; | ||
121 | break; | ||
122 | |||
123 | default: | ||
124 | strlevel = "<unknown>"; | ||
125 | break; | ||
126 | } | ||
127 | |||
128 | fprintf(stderr, "[%s] %s:%d(%s) %s\n", strlevel, file, line, func, message); | ||
129 | } | ||
130 | |||
97 | int main(int argc, char *argv[]) | 131 | int main(int argc, char *argv[]) |
98 | { | 132 | { |
99 | if (argc == 2 && !tox_strncasecmp(argv[1], "-h", 3)) { | 133 | if (argc == 2 && !tox_strncasecmp(argv[1], "-h", 3)) { |
@@ -116,6 +150,11 @@ int main(int argc, char *argv[]) | |||
116 | ip_init(&ip, ipv6enabled); | 150 | ip_init(&ip, ipv6enabled); |
117 | 151 | ||
118 | Logger *logger = logger_new(); | 152 | Logger *logger = logger_new(); |
153 | |||
154 | if (MIN_LOGGER_LEVEL == LOGGER_LEVEL_TRACE || MIN_LOGGER_LEVEL == LOGGER_LEVEL_DEBUG) { | ||
155 | logger_callback_log(logger, print_log, nullptr, nullptr); | ||
156 | } | ||
157 | |||
119 | Mono_Time *mono_time = mono_time_new(); | 158 | Mono_Time *mono_time = mono_time_new(); |
120 | DHT *dht = new_dht(logger, mono_time, new_networking(logger, ip, PORT), true); | 159 | DHT *dht = new_dht(logger, mono_time, new_networking(logger, ip, PORT), true); |
121 | Onion *onion = new_onion(mono_time, dht); | 160 | Onion *onion = new_onion(mono_time, dht); |