Class: Gitlab::Logger
- Inherits:
-
Logger
- Object
- Logger
- Gitlab::Logger
show all
- Defined in:
- lib/gitlab/logger.rb
Class Method Summary
collapse
Class Method Details
.build ⇒ Object
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: log_level)
end
|
.cache_key ⇒ Object
47
48
49
|
# File 'lib/gitlab/logger.rb', line 47
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_name ⇒ Object
5
6
7
|
# File 'lib/gitlab/logger.rb', line 5
def self.file_name
file_name_noext + '.log'
end
|
.full_log_path ⇒ Object
43
44
45
|
# File 'lib/gitlab/logger.rb', line 43
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
|
.log_level(fallback: ::Logger::DEBUG) ⇒ Object
39
40
41
|
# File 'lib/gitlab/logger.rb', line 39
def self.log_level(fallback: ::Logger::DEBUG)
ENV.fetch('GITLAB_LOG_LEVEL', fallback)
end
|
.read_latest ⇒ Object
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
|