Commit 74b68852 authored by Peter Leitzen's avatar Peter Leitzen

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

Use AppLogger in some files in lib/gitlab/*

See merge request gitlab-org/gitlab!41290
parents 3efd3678 fcdb7cf5
---
title: Use GitLab AppLogger
merge_request: 41290
author: Rajendra Kadam
type: other
......@@ -34,11 +34,11 @@ module EE
if config.admin_group.present?
sync_admin_users
else
logger.debug { "No `admin_group` configured for '#{provider}' provider. Skipping" }
logger.debug "No `admin_group` configured for '#{provider}' provider. Skipping"
end
if config.external_groups.empty?
logger.debug { "No `external_groups` configured for '#{provider}' provider. Skipping" }
logger.debug "No `external_groups` configured for '#{provider}' provider. Skipping"
else
sync_external_users
end
......@@ -49,32 +49,32 @@ module EE
private
def sync_groups
logger.debug { "Performing LDAP group sync for '#{provider}' provider" }
logger.debug "Performing LDAP group sync for '#{provider}' provider"
groups_where_group_links_with_provider_ordered.each do |group|
Sync::Group.execute(group, proxy)
end
logger.debug { "Finished LDAP group sync for '#{provider}' provider" }
logger.debug "Finished LDAP group sync for '#{provider}' provider"
end
def sync_admin_users
logger.debug { "Syncing admin users for '#{provider}' provider" }
logger.debug "Syncing admin users for '#{provider}' provider"
if Sync::AdminUsers.execute(proxy)
logger.debug { "Finished syncing admin users for '#{provider}' provider" }
logger.debug "Finished syncing admin users for '#{provider}' provider"
else
logger.debug { "Error syncing admin users for '#{provider}' provider. LDAP connection error" }
logger.debug "Error syncing admin users for '#{provider}' provider. LDAP connection error"
end
end
def sync_external_users
logger.debug { "Syncing external users for '#{provider}' provider" }
logger.debug "Syncing external users for '#{provider}' provider"
if Sync::ExternalUsers.execute(proxy)
logger.debug { "Finished syncing external users for '#{provider}' provider" }
logger.debug "Finished syncing external users for '#{provider}' provider"
else
logger.debug { "Error syncing external users for '#{provider}' provider. LDAP connection error" }
logger.debug "Error syncing external users for '#{provider}' provider. LDAP connection error"
end
end
......@@ -92,7 +92,7 @@ module EE
end
def logger
Rails.logger # rubocop:disable Gitlab/RailsLogger
::Gitlab::AppLogger
end
end
end
......
......@@ -45,7 +45,7 @@ module Gitlab
def self.normalize_dn(dn)
::Gitlab::Auth::Ldap::DN.new(dn).to_normalized_s
rescue ::Gitlab::Auth::Ldap::DN::FormatError => e
Gitlab::AppLogger.info("Returning original DN \"#{dn}\" due to error during normalization attempt: #{e.message}") # rubocop:disable Gitlab/RailsLogger
Gitlab::AppLogger.info("Returning original DN \"#{dn}\" due to error during normalization attempt: #{e.message}")
dn
end
......
......@@ -51,10 +51,8 @@ module Gitlab
redis_cmd do |redis|
current_value = redis.decr(key)
if current_value < 0
# rubocop:disable Gitlab/RailsLogger
Rails.logger.warn("Reference counter for #{gl_repository} decreased" \
Gitlab::AppLogger.warn("Reference counter for #{gl_repository} decreased" \
" when its value was less than 1. Resetting the counter.")
# rubocop:enable Gitlab/RailsLogger
redis.del(key)
end
end
......@@ -87,7 +85,7 @@ module Gitlab
true
rescue => e
Rails.logger.warn("GitLab: An unexpected error occurred in writing to Redis: #{e}") # rubocop:disable Gitlab/RailsLogger
Gitlab::AppLogger.warn("GitLab: An unexpected error occurred in writing to Redis: #{e}")
false
end
......
......@@ -21,7 +21,7 @@ RSpec.describe Gitlab::ReferenceCounter, :clean_gitlab_redis_shared_state do
end
it 'warns if attempting to decrease a counter with a value of zero or less, and resets the counter' do
expect(Rails.logger).to receive(:warn).with("Reference counter for project-1" \
expect(Gitlab::AppLogger).to receive(:warn).with("Reference counter for project-1" \
" decreased when its value was less than 1. Resetting the counter.")
expect { reference_counter.decrease }.not_to change { reference_counter.value }
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