summaryrefslogtreecommitdiff
path: root/toxcore/network.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-08-19 13:07:45 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-08-27 01:16:14 +0100
commit13ae9e9a93a1c02fad9475002c0391b86b7ad7bb (patch)
treea9575d3582c4f40e051c93ae18dded03fdddc432 /toxcore/network.h
parent1f25fc0ae417bfc47dea4966cb5e43689aa88d5c (diff)
Move logging to a callback.
This removes the global logger (which by the way was deleted when the first tox was killed, so other toxes would then stop logging). Various bits of the code now carry a logger or pass it around. It's a bit less transparent now, but now there is no need to have a global logger, and clients can decide what to log and where.
Diffstat (limited to 'toxcore/network.h')
-rw-r--r--toxcore/network.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/toxcore/network.h b/toxcore/network.h
index 97927299..1cd1c999 100644
--- a/toxcore/network.h
+++ b/toxcore/network.h
@@ -29,6 +29,8 @@
29#include <libc.h> 29#include <libc.h>
30#endif 30#endif
31 31
32#include "logger.h"
33
32#include <stdlib.h> 34#include <stdlib.h>
33#include <stdio.h> 35#include <stdio.h>
34#include <stdint.h> 36#include <stdint.h>
@@ -299,6 +301,7 @@ typedef struct {
299} Packet_Handles; 301} Packet_Handles;
300 302
301typedef struct { 303typedef struct {
304 Logger *log;
302 Packet_Handles packethandlers[256]; 305 Packet_Handles packethandlers[256];
303 306
304 sa_family_t family; 307 sa_family_t family;
@@ -377,8 +380,8 @@ void networking_poll(Networking_Core *net, void *userdata);
377 * 380 *
378 * If error is non NULL it is set to 0 if no issues, 1 if socket related error, 2 if other. 381 * If error is non NULL it is set to 0 if no issues, 1 if socket related error, 2 if other.
379 */ 382 */
380Networking_Core *new_networking(IP ip, uint16_t port); 383Networking_Core *new_networking(Logger *log, IP ip, uint16_t port);
381Networking_Core *new_networking_ex(IP ip, uint16_t port_from, uint16_t port_to, unsigned int *error); 384Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint16_t port_to, unsigned int *error);
382 385
383/* Function to cleanup networking stuff (doesn't do much right now). */ 386/* Function to cleanup networking stuff (doesn't do much right now). */
384void kill_networking(Networking_Core *net); 387void kill_networking(Networking_Core *net);