Commit e6496703 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'app-logger-14' into 'master'

Use applogger in lib/gitlab/

See merge request gitlab-org/gitlab!41071
parents 7dc3a5f5 55c60f05
---
title: Use applogger in lib/gitlab/
merge_request: 41071
author: Rajendra Kadam
type: other
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
def self.delivering_email(message) def self.delivering_email(message)
message.perform_deliveries = false message.perform_deliveries = false
Rails.logger.info "Emails disabled! Interceptor prevented sending mail #{message.subject}" # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.info "Emails disabled! Interceptor prevented sending mail #{message.subject}"
end end
end end
end end
......
...@@ -27,7 +27,7 @@ module Gitlab ...@@ -27,7 +27,7 @@ module Gitlab
# This will still fail if the file is corrupted (e.g. 0 bytes) # This will still fail if the file is corrupted (e.g. 0 bytes)
raw_repository.write_ref(keep_around_ref_name(sha), sha) raw_repository.write_ref(keep_around_ref_name(sha), sha)
rescue Gitlab::Git::CommandError => ex rescue Gitlab::Git::CommandError => ex
Rails.logger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}" # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}"
end end
end end
......
...@@ -955,7 +955,7 @@ module Gitlab ...@@ -955,7 +955,7 @@ module Gitlab
gitaly_repository_client.cleanup if exists? gitaly_repository_client.cleanup if exists?
end end
rescue Gitlab::Git::CommandError => e # Don't fail if we can't cleanup rescue Gitlab::Git::CommandError => e # Don't fail if we can't cleanup
Rails.logger.error("Unable to clean repository on storage #{storage} with relative path #{relative_path}: #{e.message}") # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.error("Unable to clean repository on storage #{storage} with relative path #{relative_path}: #{e.message}")
Gitlab::Metrics.counter( Gitlab::Metrics.counter(
:failed_repository_cleanup_total, :failed_repository_cleanup_total,
'Number of failed repository cleanup events' 'Number of failed repository cleanup events'
......
...@@ -62,28 +62,24 @@ module Gitlab ...@@ -62,28 +62,24 @@ module Gitlab
# Flag a project to be migrated to Hashed Storage # Flag a project to be migrated to Hashed Storage
# #
# @param [Project] project that will be migrated # @param [Project] project that will be migrated
# rubocop:disable Gitlab/RailsLogger
def migrate(project) def migrate(project)
Rails.logger.info "Starting storage migration of #{project.full_path} (ID=#{project.id})..." Gitlab::AppLogger.info "Starting storage migration of #{project.full_path} (ID=#{project.id})..."
project.migrate_to_hashed_storage! project.migrate_to_hashed_storage!
rescue => err rescue => err
Rails.logger.error("#{err.message} migrating storage of #{project.full_path} (ID=#{project.id}), trace - #{err.backtrace}") Gitlab::AppLogger.error("#{err.message} migrating storage of #{project.full_path} (ID=#{project.id}), trace - #{err.backtrace}")
end end
# rubocop:enable Gitlab/RailsLogger
# Flag a project to be rolled-back to Legacy Storage # Flag a project to be rolled-back to Legacy Storage
# #
# @param [Project] project that will be rolled-back # @param [Project] project that will be rolled-back
# rubocop:disable Gitlab/RailsLogger
def rollback(project) def rollback(project)
Rails.logger.info "Starting storage rollback of #{project.full_path} (ID=#{project.id})..." Gitlab::AppLogger.info "Starting storage rollback of #{project.full_path} (ID=#{project.id})..."
project.rollback_to_legacy_storage! project.rollback_to_legacy_storage!
rescue => err rescue => err
Rails.logger.error("#{err.message} rolling-back storage of #{project.full_path} (ID=#{project.id}), trace - #{err.backtrace}") Gitlab::AppLogger.error("#{err.message} rolling-back storage of #{project.full_path} (ID=#{project.id}), trace - #{err.backtrace}")
end end
# rubocop:enable Gitlab/RailsLogger
# Returns whether we have any pending storage migration # Returns whether we have any pending storage migration
# #
......
...@@ -24,7 +24,7 @@ module Gitlab ...@@ -24,7 +24,7 @@ module Gitlab
result, elapsed = with_timing(&method(:check)) result, elapsed = with_timing(&method(:check))
return if result.nil? return if result.nil?
Rails.logger.error("#{human_name} check returned unexpected result #{result}") unless successful?(result) # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.error("#{human_name} check returned unexpected result #{result}") unless successful?(result)
[ [
metric("#{metric_prefix}_timeout", result.is_a?(Timeout::Error) ? 1 : 0), metric("#{metric_prefix}_timeout", result.is_a?(Timeout::Error) ? 1 : 0),
metric("#{metric_prefix}_success", successful?(result) ? 1 : 0), metric("#{metric_prefix}_success", successful?(result) ? 1 : 0),
......
...@@ -21,7 +21,7 @@ module Gitlab ...@@ -21,7 +21,7 @@ module Gitlab
def safe_sample def safe_sample
sample sample
rescue => e rescue => e
Rails.logger.warn("#{self.class}: #{e}, stopping") # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn("#{self.class}: #{e}, stopping")
stop stop
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