From 07e23c70f1b3db4c10de22989d3bacd2cf56abf3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Sun, 6 Sep 2020 12:08:40 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- changelogs/unreleased/app-logger-17.yml | 5 +++++ lib/gitlab/auth/ldap/config.rb | 4 ++-- lib/gitlab/repository_cache_adapter.rb | 2 +- spec/lib/gitlab/auth/ldap/config_spec.rb | 4 ++-- spec/lib/gitlab/repository_cache_adapter_spec.rb | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/app-logger-17.yml diff --git a/changelogs/unreleased/app-logger-17.yml b/changelogs/unreleased/app-logger-17.yml new file mode 100644 index 00000000000..17352164606 --- /dev/null +++ b/changelogs/unreleased/app-logger-17.yml @@ -0,0 +1,5 @@ +--- +title: Use GitLab AppLogger +merge_request: 41261 +author: Rajendra Kadam +type: other diff --git a/lib/gitlab/auth/ldap/config.rb b/lib/gitlab/auth/ldap/config.rb index 7677189eb9f..88cc840c395 100644 --- a/lib/gitlab/auth/ldap/config.rb +++ b/lib/gitlab/auth/ldap/config.rb @@ -248,7 +248,7 @@ module Gitlab begin custom_options[:cert] = OpenSSL::X509::Certificate.new(custom_options[:cert]) rescue OpenSSL::X509::CertificateError => e - Rails.logger.error "LDAP TLS Options 'cert' is invalid for provider #{provider}: #{e.message}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error "LDAP TLS Options 'cert' is invalid for provider #{provider}: #{e.message}" end end @@ -256,7 +256,7 @@ module Gitlab begin custom_options[:key] = OpenSSL::PKey.read(custom_options[:key]) rescue OpenSSL::PKey::PKeyError => e - Rails.logger.error "LDAP TLS Options 'key' is invalid for provider #{provider}: #{e.message}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error "LDAP TLS Options 'key' is invalid for provider #{provider}: #{e.message}" end end diff --git a/lib/gitlab/repository_cache_adapter.rb b/lib/gitlab/repository_cache_adapter.rb index f6a5c6ed754..eb7c9bccf96 100644 --- a/lib/gitlab/repository_cache_adapter.rb +++ b/lib/gitlab/repository_cache_adapter.rb @@ -218,7 +218,7 @@ module Gitlab def expire_method_caches(methods) methods.each do |name| unless cached_methods.include?(name.to_sym) - Rails.logger.error "Requested to expire non-existent method '#{name}' for Repository" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error "Requested to expire non-existent method '#{name}' for Repository" next end diff --git a/spec/lib/gitlab/auth/ldap/config_spec.rb b/spec/lib/gitlab/auth/ldap/config_spec.rb index 4287596af8f..e4c87a54365 100644 --- a/spec/lib/gitlab/auth/ldap/config_spec.rb +++ b/spec/lib/gitlab/auth/ldap/config_spec.rb @@ -168,7 +168,7 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK end it 'logs an error when an invalid key or cert are configured' do - allow(Rails.logger).to receive(:error) + allow(Gitlab::AppLogger).to receive(:error) stub_ldap_config( options: { 'host' => 'ldap.example.com', @@ -183,7 +183,7 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK config.adapter_options - expect(Rails.logger).to have_received(:error).with(/LDAP TLS Options/).twice + expect(Gitlab::AppLogger).to have_received(:error).with(/LDAP TLS Options/).twice end context 'when verify_certificates is enabled' do diff --git a/spec/lib/gitlab/repository_cache_adapter_spec.rb b/spec/lib/gitlab/repository_cache_adapter_spec.rb index c9ad79234d3..4c57665b41f 100644 --- a/spec/lib/gitlab/repository_cache_adapter_spec.rb +++ b/spec/lib/gitlab/repository_cache_adapter_spec.rb @@ -302,7 +302,7 @@ RSpec.describe Gitlab::RepositoryCacheAdapter do it 'does not expire caches for non-existent methods' do expect(cache).not_to receive(:expire).with(:nonexistent) - expect(Rails.logger).to( + expect(Gitlab::AppLogger).to( receive(:error).with("Requested to expire non-existent method 'nonexistent' for Repository")) repository.expire_method_caches(%i(nonexistent)) -- GitLab