if (var) { \
struct timeval _tv; \
struct tm _tm; \
char _tbuf[20]; \
time_t _tsecs; \
gettimeofday(&_tv, NULL); \
_tsecs = _tv.tv_sec; \
localtime_r(&_tsecs, &_tm); \
strftime(_tbuf, 20, "%H:%M:%S", &_tm); \
fprintf(file,
"[" col who
" - " lev
ANSI_RESET " %s.%06ld] ", _tbuf, \
(long) _tv.tv_usec); \
fprintf(file, __VA_ARGS__); \
}
44#define D(var, file, col, who, lev, ...) \
45 if (var) { \
46 struct timeval _tv; \
47 struct tm _tm; \
48 char _tbuf[20]; \
49 time_t _tsecs; \
50 gettimeofday(&_tv, NULL); \
51 _tsecs = _tv.tv_sec; \
52 localtime_r(&_tsecs, &_tm); \
53 strftime(_tbuf, 20, "%H:%M:%S", &_tm); \
54 fprintf(file, "[" col who " - " lev ANSI_RESET " %s.%06ld] ", _tbuf, \
55 (long) _tv.tv_usec); \
56 fprintf(file, "%s:%d (%s): ", __FILENAME__, __LINE__, __func__); \
57 fprintf(file, __VA_ARGS__); \
58 }