summaryrefslogtreecommitdiff
path: root/lib/gitlab_logger.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-03-23 12:24:34 +0000
committerDouwe Maan <douwe@gitlab.com>2018-03-23 12:24:34 +0000
commit69941f9075b64e8ed518a33e87b00c52169f4dbf (patch)
tree0023ae5c66b9da5250ed914ae93d665f7250df88 /lib/gitlab_logger.rb
parente19b08ba3f985eacfdf0ecf1c06799959d02cfe7 (diff)
parent9087e96083fcfe22c2cb111add55d3d0009eda9a (diff)
downloadgitlab-shell-69941f9075b64e8ed518a33e87b00c52169f4dbf.tar.gz
Merge branch 'log-flush' into 'master'v7.1.1
Flush log file after every write See merge request gitlab-org/gitlab-shell!199
Diffstat (limited to 'lib/gitlab_logger.rb')
-rw-r--r--lib/gitlab_logger.rb6
1 files changed, 6 insertions, 0 deletions
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