mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 14:43:03 +01:00
Add higher precision for logging timestamps
This commit is contained in:
parent
529d905bd0
commit
4f936e5f9c
11
src/toxic.c
11
src/toxic.c
@ -37,6 +37,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -267,12 +268,14 @@ void cb_toxcore_logger(Tox *m, TOX_LOG_LEVEL level, const char *file, uint32_t l
|
|||||||
fp = stderr;
|
fp = stderr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const time_t t = time(NULL);
|
struct timeval tv;
|
||||||
struct tm *tmp = gmtime(&t);
|
gettimeofday(&tv, NULL);
|
||||||
|
struct tm tmp;
|
||||||
|
gmtime_r(&tv.tv_sec, &tmp);
|
||||||
char timestamp[200];
|
char timestamp[200];
|
||||||
strftime(timestamp, sizeof(timestamp), "%F %T", tmp);
|
strftime(timestamp, sizeof(timestamp), "%F %T", &tmp);
|
||||||
|
|
||||||
fprintf(fp, "[%c] %s %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, file, line, func, message);
|
fprintf(fp, "%c %s.%06ld %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, tv.tv_usec, file, line, func, message);
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user