From 5bf9f7e439a6620134b6052b09e6f5a255edf742 Mon Sep 17 00:00:00 2001 From: Symeon Huang Date: Thu, 13 Nov 2014 23:55:34 +0000 Subject: [PATCH] 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. --- src/utils.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils.h b/src/utils.h index bd794511..118c3981 100644 --- a/src/utils.h +++ b/src/utils.h @@ -98,7 +98,8 @@ extern FILE * logfile; time_t now = time(NULL); \ char timestr[20]; \ 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) #define LOGE(format, ...) \ @@ -106,7 +107,8 @@ extern FILE * logfile; time_t now = time(NULL); \ char timestr[20]; \ 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) #else