diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-19 13:07:45 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-27 01:16:14 +0100 |
commit | 13ae9e9a93a1c02fad9475002c0391b86b7ad7bb (patch) | |
tree | a9575d3582c4f40e051c93ae18dded03fdddc432 /toxcore/network.h | |
parent | 1f25fc0ae417bfc47dea4966cb5e43689aa88d5c (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.h | 7 |
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 | ||
301 | typedef struct { | 303 | typedef 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 | */ |
380 | Networking_Core *new_networking(IP ip, uint16_t port); | 383 | Networking_Core *new_networking(Logger *log, IP ip, uint16_t port); |
381 | Networking_Core *new_networking_ex(IP ip, uint16_t port_from, uint16_t port_to, unsigned int *error); | 384 | Networking_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). */ |
384 | void kill_networking(Networking_Core *net); | 387 | void kill_networking(Networking_Core *net); |