Class: Gitlab::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/gitlab/logger.rb

Class Method Summary collapse

Class Method Details

.buildObject


34
35
36
37
# File 'lib/gitlab/logger.rb', line 34

def self.build
  Gitlab::SafeRequestStore[self.cache_key] ||=
    new(self.full_log_path, level: ::Logger::DEBUG)
end

.cache_keyObject


43
44
45
# File 'lib/gitlab/logger.rb', line 43

def self.cache_key
  'logger:' + self.full_log_path.to_s
end

.debug(message) ⇒ Object


9
10
11
# File 'lib/gitlab/logger.rb', line 9

def self.debug(message)
  build.debug(message)
end

.error(message) ⇒ Object


13
14
15
# File 'lib/gitlab/logger.rb', line 13

def self.error(message)
  build.error(message)
end

.file_nameObject


5
6
7
# File 'lib/gitlab/logger.rb', line 5

def self.file_name
  file_name_noext + '.log'
end

.full_log_pathObject


39
40
41
# File 'lib/gitlab/logger.rb', line 39

def self.full_log_path
  Rails.root.join("log", file_name)
end

.info(message) ⇒ Object


21
22
23
# File 'lib/gitlab/logger.rb', line 21

def self.info(message)
  build.info(message)
end

.read_latestObject


25
26
27
28
29
30
31
32
# File 'lib/gitlab/logger.rb', line 25

def self.read_latest
  path = self.full_log_path

  return [] unless File.readable?(path)

  tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
  tail_output.split("\n")
end

.warn(message) ⇒ Object


17
18
19
# File 'lib/gitlab/logger.rb', line 17

def self.warn(message)
  build.warn(message)
end