From 9087e96083fcfe22c2cb111add55d3d0009eda9a Mon Sep 17 00:00:00 2001 From: "Jacob Vosmaer (GitLab)" Date: Fri, 23 Mar 2018 12:24:34 +0000 Subject: Flush log file after every write --- lib/gitlab_logger.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/gitlab_logger.rb b/lib/gitlab_logger.rb index cdca25b..f81c2f6 100644 --- a/lib/gitlab_logger.rb +++ b/lib/gitlab_logger.rb @@ -25,7 +25,13 @@ class GitlabLogger def initialize(level, path, log_format) @level = level + @log_file = File.open(path, 'ab') + # By default Ruby will buffer writes. This is a problem when we exec + # into a new command before Ruby flushed its buffers. Setting 'sync' to + # true disables Ruby's buffering. + @log_file.sync = true + @log_format = log_format end -- cgit v1.2.1