2012-05-26 06:37:49 -04:00
|
|
|
module Gitlab
|
2012-07-17 01:23:16 -04:00
|
|
|
class Logger < ::Logger
|
2014-10-04 11:09:06 -04:00
|
|
|
def self.file_name
|
|
|
|
file_name_noext + '.log'
|
|
|
|
end
|
|
|
|
|
2012-05-21 16:17:41 -04:00
|
|
|
def self.error(message)
|
2012-07-17 01:23:16 -04:00
|
|
|
build.error(message)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.info(message)
|
|
|
|
build.info(message)
|
2012-05-21 16:17:41 -04:00
|
|
|
end
|
2012-07-05 14:59:37 -04:00
|
|
|
|
|
|
|
def self.read_latest
|
2012-09-11 16:24:53 -04:00
|
|
|
path = Rails.root.join("log", file_name)
|
2012-07-21 10:30:09 -04:00
|
|
|
self.build unless File.exist?(path)
|
2014-02-25 06:12:09 -05:00
|
|
|
tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
|
|
|
|
tail_output.split("\n")
|
2012-07-05 14:59:37 -04:00
|
|
|
end
|
2012-07-17 01:23:16 -04:00
|
|
|
|
2014-09-25 18:07:40 -04:00
|
|
|
def self.read_latest_for(filename)
|
2012-12-18 23:14:05 -05:00
|
|
|
path = Rails.root.join("log", filename)
|
2014-02-25 06:12:09 -05:00
|
|
|
tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
|
|
|
|
tail_output.split("\n")
|
2012-12-18 23:14:05 -05:00
|
|
|
end
|
|
|
|
|
2012-07-17 01:23:16 -04:00
|
|
|
def self.build
|
2012-09-26 14:52:01 -04:00
|
|
|
new(Rails.root.join("log", file_name))
|
2012-07-17 01:23:16 -04:00
|
|
|
end
|
2012-05-21 16:17:41 -04:00
|
|
|
end
|
|
|
|
end
|