Browse Source

fflush stderr on Windows.

unfortunately, Windows will buffer stderr if it's not executed in `cmd.exe`,
which will cause unpleasant buffered log output. adding fflush(stderr) will
solve this aged issue.
pull/150/head
Symeon Huang 10 years ago
parent
commit
5bf9f7e439
1 changed files with 4 additions and 2 deletions
  1. 6
      src/utils.h

6
src/utils.h

@ -98,7 +98,8 @@ extern FILE * logfile;
time_t now = time(NULL); \ time_t now = time(NULL); \
char timestr[20]; \ char timestr[20]; \
strftime(timestr, 20, TIME_FORMAT, localtime(&now)); \ strftime(timestr, 20, TIME_FORMAT, localtime(&now)); \
fprintf(stderr, " %s INFO: " format "\n", timestr, ## __VA_ARGS__); } \
fprintf(stderr, " %s INFO: " format "\n", timestr, ## __VA_ARGS__); \
fflush(stderr); } \
while (0) while (0)
#define LOGE(format, ...) \ #define LOGE(format, ...) \
@ -106,7 +107,8 @@ extern FILE * logfile;
time_t now = time(NULL); \ time_t now = time(NULL); \
char timestr[20]; \ char timestr[20]; \
strftime(timestr, 20, TIME_FORMAT, localtime(&now)); \ strftime(timestr, 20, TIME_FORMAT, localtime(&now)); \
fprintf(stderr, " %s ERROR: " format "\n", timestr, ## __VA_ARGS__); } \
fprintf(stderr, " %s ERROR: " format "\n", timestr, ## __VA_ARGS__); \
fflush(stderr); } \
while (0) while (0)
#else #else

Loading…
Cancel
Save