BigW Consortium Gitlab

logger.rb 726 Bytes
Newer Older
1
module Gitlab
2
  class Logger < ::Logger
Ciro Santilli committed
3 4 5 6
    def self.file_name
      file_name_noext + '.log'
    end

7
    def self.error(message)
8 9 10 11 12
      build.error(message)
    end

    def self.info(message)
      build.info(message)
13
    end
14 15

    def self.read_latest
randx committed
16
      path = Rails.root.join("log", file_name)
17
      self.build unless File.exist?(path)
18 19
      tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
      tail_output.split("\n")
20
    end
21

22
    def self.read_latest_for(filename)
23
      path = Rails.root.join("log", filename)
24 25
      tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
      tail_output.split("\n")
26 27
    end

28
    def self.build
29
      new(Rails.root.join("log", file_name))
30
    end
31 32
  end
end