mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Merge pull request #640 from FullName/logging_fixes
Behind #define LOGGING: Correct usage of now() to replacement unix_time().
This commit is contained in:
commit
4bf4b3f47c
|
@ -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++) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user