Commit e1b4e6a9 authored by Toon Claes's avatar Toon Claes

DRY up things further in LogCursor::Logger

parent 406c702a
......@@ -303,10 +303,12 @@ module Gitlab
def logger
strong_memoize(:logger) do
level = options[:debug] ? :debug : Rails.logger.level
Gitlab::Geo::LogCursor::Logger.new(self.class, level)
Gitlab::Geo::LogCursor::Logger.new(self.class, log_level)
end
end
def log_level
options[:debug] ? :debug : Rails.logger.level
end
end
end
......
......@@ -6,29 +6,27 @@ module Gitlab
PID = Process.pid.freeze
def initialize(klass, level = Rails.logger.level)
def initialize(klass, level = nil)
@klass = klass
geo_logger.build.level = level
geo_logger.build.level = level unless level.nil?
end
def event_info(created_at, message, params = {})
args = base_log_data(message).merge(
cursor_delay_s: cursor_delay(created_at)
).merge(params)
params = params.merge(cursor_delay_s: cursor_delay(created_at))
geo_logger.info(args)
info(message, params)
end
def info(message, params = {})
geo_logger.info(base_log_data(message).merge(params))
geo_logger.info(base_log_data(message, params))
end
def error(message, params = {})
geo_logger.error(base_log_data(message).merge(params))
geo_logger.error(base_log_data(message, params))
end
def debug(message, params = {})
geo_logger.debug(base_log_data(message).merge(params))
geo_logger.debug(base_log_data(message, params))
end
private
......@@ -45,12 +43,12 @@ module Gitlab
(Time.now - created_at).to_f.round(3)
end
def base_log_data(message)
def base_log_data(message, params = {})
{
pid: PID,
class: caller_name,
message: message
}
}.merge(params)
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