Commit e1b4e6a9 authored by Toon Claes's avatar Toon Claes

DRY up things further in LogCursor::Logger

parent 406c702a
...@@ -303,11 +303,13 @@ module Gitlab ...@@ -303,11 +303,13 @@ module Gitlab
def logger def logger
strong_memoize(:logger) do strong_memoize(:logger) do
level = options[:debug] ? :debug : Rails.logger.level Gitlab::Geo::LogCursor::Logger.new(self.class, log_level)
Gitlab::Geo::LogCursor::Logger.new(self.class, level)
end end
end end
def log_level
options[:debug] ? :debug : Rails.logger.level
end
end end
end end
end end
......
...@@ -6,29 +6,27 @@ module Gitlab ...@@ -6,29 +6,27 @@ module Gitlab
PID = Process.pid.freeze PID = Process.pid.freeze
def initialize(klass, level = Rails.logger.level) def initialize(klass, level = nil)
@klass = klass @klass = klass
geo_logger.build.level = level geo_logger.build.level = level unless level.nil?
end end
def event_info(created_at, message, params = {}) def event_info(created_at, message, params = {})
args = base_log_data(message).merge( params = params.merge(cursor_delay_s: cursor_delay(created_at))
cursor_delay_s: cursor_delay(created_at)
).merge(params)
geo_logger.info(args) info(message, params)
end end
def info(message, params = {}) def info(message, params = {})
geo_logger.info(base_log_data(message).merge(params)) geo_logger.info(base_log_data(message, params))
end end
def error(message, params = {}) def error(message, params = {})
geo_logger.error(base_log_data(message).merge(params)) geo_logger.error(base_log_data(message, params))
end end
def debug(message, params = {}) def debug(message, params = {})
geo_logger.debug(base_log_data(message).merge(params)) geo_logger.debug(base_log_data(message, params))
end end
private private
...@@ -45,12 +43,12 @@ module Gitlab ...@@ -45,12 +43,12 @@ module Gitlab
(Time.now - created_at).to_f.round(3) (Time.now - created_at).to_f.round(3)
end end
def base_log_data(message) def base_log_data(message, params = {})
{ {
pid: PID, pid: PID,
class: caller_name, class: caller_name,
message: message message: message
} }.merge(params)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment