From a164c90e28423dae7fd3a6ab70ab23f6ceeebb46 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Thu, 8 Sep 2016 07:58:52 -0500 Subject: [PATCH] Flush the stdout buffer after logging to console Normally if the stdout is connected to a PTY, the stdout buffer is flushed automatically after each \n. However if I run SRS under Docker, the stdout is not connected to a PTY (unless I ask it to), causing the last log line to be incomplete (showing only half). By adding fflush, we could make sure each log line is completely shown, whenever the stdout is connected to a PTY or not. --- trunk/src/app/srs_app_log.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/trunk/src/app/srs_app_log.cpp b/trunk/src/app/srs_app_log.cpp index e82319aae..67f26930b 100644 --- a/trunk/src/app/srs_app_log.cpp +++ b/trunk/src/app/srs_app_log.cpp @@ -382,6 +382,7 @@ void SrsFastLog::write_log(int& fd, char *str_log, int size, int level) } else{ printf("\033[31m%.*s\033[0m", size, str_log); } + fflush(stdout); return; }