Commit 17f430c2 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'rails-logger-cop-2' into 'master'

Use appLogger in project.rb

See merge request gitlab-org/gitlab!32183
parents 9ed1e151 ab0a7ea9
...@@ -925,17 +925,15 @@ class Project < ApplicationRecord ...@@ -925,17 +925,15 @@ class Project < ApplicationRecord
job_id job_id
end end
# rubocop:disable Gitlab/RailsLogger
def log_import_activity(job_id, type: :import) def log_import_activity(job_id, type: :import)
job_type = type.to_s.capitalize job_type = type.to_s.capitalize
if job_id if job_id
Rails.logger.info("#{job_type} job scheduled for #{full_path} with job ID #{job_id}.") Gitlab::AppLogger.info("#{job_type} job scheduled for #{full_path} with job ID #{job_id}.")
else else
Rails.logger.error("#{job_type} job failed to create for #{full_path}.") Gitlab::AppLogger.error("#{job_type} job failed to create for #{full_path}.")
end end
end end
# rubocop:enable Gitlab/RailsLogger
def reset_cache_and_import_attrs def reset_cache_and_import_attrs
run_after_commit do run_after_commit do
...@@ -1776,17 +1774,15 @@ class Project < ApplicationRecord ...@@ -1776,17 +1774,15 @@ class Project < ApplicationRecord
ensure_pages_metadatum.update!(deployed: false) ensure_pages_metadatum.update!(deployed: false)
end end
# rubocop:disable Gitlab/RailsLogger
def write_repository_config(gl_full_path: full_path) def write_repository_config(gl_full_path: full_path)
# We'd need to keep track of project full path otherwise directory tree # We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using # created with hashed storage enabled cannot be usefully imported using
# the import rake task. # the import rake task.
repository.raw_repository.write_config(full_path: gl_full_path) repository.raw_repository.write_config(full_path: gl_full_path)
rescue Gitlab::Git::Repository::NoRepository => e rescue Gitlab::Git::Repository::NoRepository => e
Rails.logger.error("Error writing to .git/config for project #{full_path} (#{id}): #{e.message}.") Gitlab::AppLogger.error("Error writing to .git/config for project #{full_path} (#{id}): #{e.message}.")
nil nil
end end
# rubocop:enable Gitlab/RailsLogger
def after_import def after_import
repository.expire_content_cache repository.expire_content_cache
...@@ -1829,17 +1825,15 @@ class Project < ApplicationRecord ...@@ -1829,17 +1825,15 @@ class Project < ApplicationRecord
@pipeline_status ||= Gitlab::Cache::Ci::ProjectPipelineStatus.load_for_project(self) @pipeline_status ||= Gitlab::Cache::Ci::ProjectPipelineStatus.load_for_project(self)
end end
# rubocop:disable Gitlab/RailsLogger
def add_export_job(current_user:, after_export_strategy: nil, params: {}) def add_export_job(current_user:, after_export_strategy: nil, params: {})
job_id = ProjectExportWorker.perform_async(current_user.id, self.id, after_export_strategy, params) job_id = ProjectExportWorker.perform_async(current_user.id, self.id, after_export_strategy, params)
if job_id if job_id
Rails.logger.info "Export job started for project ID #{self.id} with job ID #{job_id}" Gitlab::AppLogger.info "Export job started for project ID #{self.id} with job ID #{job_id}"
else else
Rails.logger.error "Export job failed to start for project ID #{self.id}" Gitlab::AppLogger.error "Export job failed to start for project ID #{self.id}"
end end
end end
# rubocop:enable Gitlab/RailsLogger
def import_export_shared def import_export_shared
@import_export_shared ||= Gitlab::ImportExport::Shared.new(self) @import_export_shared ||= Gitlab::ImportExport::Shared.new(self)
......
---
title: Use applogger in project.rb
merge_request: 32183
author: Rajendra Kadam
type: fixed
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