From 03485a8d05aa63dadb29001eac8593925db00b42 Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Wed, 6 Nov 2013 15:25:23 +0100 Subject: [PATCH] Behind #define LOGGING: Correct usage of now() to replacement unix_time(). --- toxcore/Messenger.c | 4 ++-- toxcore/util.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index c73161d3..659c837b 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -1806,10 +1806,10 @@ void do_messenger(Messenger *m) #ifdef LOGGING - if (now() > lastdump + DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS) { + if (unix_time() > lastdump + DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS) { loglog(" = = = = = = = = \n"); - lastdump = now(); + lastdump = unix_time(); uint32_t client, last_pinged; for (client = 0; client < LCLIENT_LIST; client++) { diff --git a/toxcore/util.c b/toxcore/util.c index d3df64c1..0cafe320 100644 --- a/toxcore/util.c +++ b/toxcore/util.c @@ -139,8 +139,10 @@ void loginit(uint16_t port) if (logfile) fclose(logfile); - if (!starttime) - starttime = now(); + if (!starttime) { + unix_time_update(); + starttime = unix_time(); + } struct tm *tm = localtime(&starttime); @@ -164,7 +166,7 @@ void loginit(uint16_t port) void loglog(char *text) { if (logfile) { - fprintf(logfile, "%4u %s", (uint32_t)(now() - starttime), text); + fprintf(logfile, "%4u %s", (uint32_t)(unix_time() - starttime), text); fflush(logfile); return; @@ -175,7 +177,9 @@ void loglog(char *text) size_t len = strlen(text); if (!starttime) { - starttime = now(); + unix_time_update(); + starttime = unix_time(); + logbufferprelen = 1024 + len - (len % 1024); logbufferpredata = malloc(logbufferprelen); logbufferprehead = logbufferpredata; @@ -193,7 +197,7 @@ void loglog(char *text) logbufferprelen = lennew; } - int written = sprintf(logbufferprehead, "%4u %s", (uint32_t)(now() - starttime), text); + int written = sprintf(logbufferprehead, "%4u %s", (uint32_t)(unix_time() - starttime), text); logbufferprehead += written; }