summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-11-06 15:25:23 +0100
committerCoren[m] <Break@Ocean>2013-11-06 15:26:08 +0100
commit03485a8d05aa63dadb29001eac8593925db00b42 (patch)
tree530412a2ead4f6cefe95f32247e17a98e919d2c3 /toxcore
parent71f7a4940247db6fd1b6f74418fd775f0f4c2bd3 (diff)
Behind #define LOGGING: Correct usage of now() to replacement unix_time().
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/Messenger.c4
-rw-r--r--toxcore/util.c14
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)
1806 1806
1807#ifdef LOGGING 1807#ifdef LOGGING
1808 1808
1809 if (now() > lastdump + DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS) { 1809 if (unix_time() > lastdump + DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS) {
1810 loglog(" = = = = = = = = \n"); 1810 loglog(" = = = = = = = = \n");
1811 1811
1812 lastdump = now(); 1812 lastdump = unix_time();
1813 uint32_t client, last_pinged; 1813 uint32_t client, last_pinged;
1814 1814
1815 for (client = 0; client < LCLIENT_LIST; client++) { 1815 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)
139 if (logfile) 139 if (logfile)
140 fclose(logfile); 140 fclose(logfile);
141 141
142 if (!starttime) 142 if (!starttime) {
143 starttime = now(); 143 unix_time_update();
144 starttime = unix_time();
145 }
144 146
145 struct tm *tm = localtime(&starttime); 147 struct tm *tm = localtime(&starttime);
146 148
@@ -164,7 +166,7 @@ void loginit(uint16_t port)
164void loglog(char *text) 166void loglog(char *text)
165{ 167{
166 if (logfile) { 168 if (logfile) {
167 fprintf(logfile, "%4u %s", (uint32_t)(now() - starttime), text); 169 fprintf(logfile, "%4u %s", (uint32_t)(unix_time() - starttime), text);
168 fflush(logfile); 170 fflush(logfile);
169 171
170 return; 172 return;
@@ -175,7 +177,9 @@ void loglog(char *text)
175 size_t len = strlen(text); 177 size_t len = strlen(text);
176 178
177 if (!starttime) { 179 if (!starttime) {
178 starttime = now(); 180 unix_time_update();
181 starttime = unix_time();
182
179 logbufferprelen = 1024 + len - (len % 1024); 183 logbufferprelen = 1024 + len - (len % 1024);
180 logbufferpredata = malloc(logbufferprelen); 184 logbufferpredata = malloc(logbufferprelen);
181 logbufferprehead = logbufferpredata; 185 logbufferprehead = logbufferpredata;
@@ -193,7 +197,7 @@ void loglog(char *text)
193 logbufferprelen = lennew; 197 logbufferprelen = lennew;
194 } 198 }
195 199
196 int written = sprintf(logbufferprehead, "%4u %s", (uint32_t)(now() - starttime), text); 200 int written = sprintf(logbufferprehead, "%4u %s", (uint32_t)(unix_time() - starttime), text);
197 logbufferprehead += written; 201 logbufferprehead += written;
198} 202}
199 203