Commit 7d125f1a authored by Toon Claes's avatar Toon Claes

Use Gitlab::Geo::LogHelpers where possible

parent 9190e081
...@@ -17,6 +17,8 @@ module Geo ...@@ -17,6 +17,8 @@ module Geo
# The `build_event` method is supposed to return an instance of the event # The `build_event` method is supposed to return an instance of the event
# that will be logged. # that will be logged.
class EventStore class EventStore
include ::Gitlab::Geo::ProjectLogHelpers
class << self class << self
attr_accessor :event_type attr_accessor :event_type
end end
...@@ -43,20 +45,5 @@ module Geo ...@@ -43,20 +45,5 @@ module Geo
raise NotImplementedError, raise NotImplementedError,
"#{self.class} does not implement #{__method__}" "#{self.class} does not implement #{__method__}"
end end
def log_error(message, error)
Gitlab::Geo::Logger.error({
class: self.class.name,
message: message,
error: error
}.merge(log_params))
end
def log_params
{
project_id: project.id,
project_path: project.full_path
}
end
end end
end end
...@@ -3,6 +3,7 @@ module Geo ...@@ -3,6 +3,7 @@ module Geo
include Sidekiq::Worker include Sidekiq::Worker
include CronjobQueue include CronjobQueue
include ExclusiveLeaseGuard include ExclusiveLeaseGuard
include ::Gitlab::Geo::LogHelpers
LEASE_TIMEOUT = 60.minutes LEASE_TIMEOUT = 60.minutes
...@@ -10,11 +11,6 @@ module Geo ...@@ -10,11 +11,6 @@ module Geo
LEASE_TIMEOUT LEASE_TIMEOUT
end end
def log_error(message, extra_args = {})
args = { class: self.class.name, message: message }.merge(extra_args)
Gitlab::Geo::Logger.error(args)
end
def perform def perform
return unless Gitlab::Geo.primary? return unless Gitlab::Geo.primary?
......
...@@ -7,9 +7,10 @@ module Gitlab ...@@ -7,9 +7,10 @@ module Gitlab
Gitlab::Geo::Logger.info(data) Gitlab::Geo::Logger.info(data)
end end
def log_error(message, error) def log_error(message, error = nil, details = {})
data = base_log_data(message) data = base_log_data(message)
data[:error] = error.to_s data[:error] = error.to_s if error
data.merge!(details) if details
Gitlab::Geo::Logger.error(data) Gitlab::Geo::Logger.error(data)
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