diff options
author | Nick Thomas <nick@gitlab.com> | 2017-10-24 12:43:30 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-10-24 12:43:30 +0000 |
commit | bf4e97fc8386fd941ea316902d4bce07c2a177b2 (patch) | |
tree | 54aeaf504709d9225d5c824fc8a4575c38970346 /lib/gitlab/logger.rb | |
parent | 7624824cc3deadd423b76c4f78c65b97ea8d82b2 (diff) | |
parent | 324b3bbaca9eb74169c8606f6a7d3279393348ff (diff) | |
download | gitlab-ce-bf4e97fc8386fd941ea316902d4bce07c2a177b2.tar.gz |
Merge branch 'sh-memoize-logger' into 'master'
Memoize GitLab logger to reduce open file descriptors
Closes gitlab-ee#3664
See merge request gitlab-org/gitlab-ce!15007
Diffstat (limited to 'lib/gitlab/logger.rb')
-rw-r--r-- | lib/gitlab/logger.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index 6bffd410ed0..a42e312b5d3 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -13,7 +13,7 @@ module Gitlab end def self.read_latest - path = Rails.root.join("log", file_name) + path = self.full_log_path return [] unless File.readable?(path) @@ -22,7 +22,15 @@ module Gitlab end def self.build - new(Rails.root.join("log", file_name)) + RequestStore[self.cache_key] ||= new(self.full_log_path) + end + + def self.full_log_path + Rails.root.join("log", file_name) + end + + def self.cache_key + 'logger:'.freeze + self.full_log_path.to_s end end end |