Skip to content

Commit 5bf9f7e

Browse files
committed
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.
1 parent a578c35 commit 5bf9f7e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,17 @@ extern FILE * logfile;
9898
time_t now = time(NULL); \
9999
char timestr[20]; \
100100
strftime(timestr, 20, TIME_FORMAT, localtime(&now)); \
101-
fprintf(stderr, " %s INFO: " format "\n", timestr, ## __VA_ARGS__); } \
101+
fprintf(stderr, " %s INFO: " format "\n", timestr, ## __VA_ARGS__); \
102+
fflush(stderr); } \
102103
while (0)
103104

104105
#define LOGE(format, ...) \
105106
do { \
106107
time_t now = time(NULL); \
107108
char timestr[20]; \
108109
strftime(timestr, 20, TIME_FORMAT, localtime(&now)); \
109-
fprintf(stderr, " %s ERROR: " format "\n", timestr, ## __VA_ARGS__); } \
110+
fprintf(stderr, " %s ERROR: " format "\n", timestr, ## __VA_ARGS__); \
111+
fflush(stderr); } \
110112
while (0)
111113

112114
#else

0 commit comments

Comments
 (0)