debian-mirror-gitlab/lib/gitlab/logger.rb

37 lines
697 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module Gitlab
class Logger < ::Logger
2015-04-26 12:48:37 +05:30
def self.file_name
file_name_noext + '.log'
end
2014-09-02 18:07:02 +05:30
def self.error(message)
build.error(message)
end
def self.info(message)
build.info(message)
end
def self.read_latest
2018-03-17 18:26:18 +05:30
path = self.full_log_path
return [] unless File.readable?(path)
2014-09-02 18:07:02 +05:30
tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
tail_output.split("\n")
end
def self.build
2018-03-17 18:26:18 +05:30
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
2014-09-02 18:07:02 +05:30
end
end
end