Migrate Geo logs to structured JSON in geo.log

parent 968f870e
......@@ -27,7 +27,7 @@ module Geo
return unless Gitlab::Geo.geo_database_configured?
return unless Gitlab::Geo.secondary?
logger.info "Started #{self.class.name}"
log_info('Started scheduler')
@start_time = Time.now
......@@ -54,7 +54,7 @@ module Geo
sleep(1)
end
logger.info "Finished #{self.class.name}"
log_info('Finished scheduler')
end
end
......@@ -128,7 +128,7 @@ module Geo
lease = exclusive_lease.try_obtain
unless lease
logger.info " #{self.class.name}: Cannot obtain an exclusive lease. There must be another worker already in execution."
log_error('Cannot obtain an exclusive lease. There must be another worker already in execution.')
return
end
......@@ -160,5 +160,13 @@ module Geo
@current_node_enabled ||= Gitlab::Geo.current_node_enabled?
end
def log_info(message)
Gitlab::Geo::Logger.info(class: self.class.name, message: message)
end
def log_error(message)
Gitlab::Geo::Logger.error(class: self.class.name, message: message)
end
end
end
......@@ -16,8 +16,13 @@ module Geo
Geo::RepositorySyncService.new(project).execute if sync_repository?(registry, scheduled_time)
Geo::WikiSyncService.new(project).execute if sync_wiki?(registry, scheduled_time)
rescue ActiveRecord::RecordNotFound
logger.error("Couldn't find project with ID=#{project_id}, skipping syncing")
rescue ActiveRecord::RecordNotFound => e
Gitlab::Geo::Logger.error(
class: self.class.name,
message: "Couldn't find project, skipping syncing",
project_id: project_id,
error: e
)
end
private
......
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