diff --git a/changelogs/unreleased/app-logger-17.yml b/changelogs/unreleased/app-logger-17.yml new file mode 100644 index 0000000000000000000000000000000000000000..173521646065776623ce41ce6a4a590dc58bd959 --- /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 7677189eb9f5e32777ad640ff574f72a2533c4eb..88cc840c395f16cc2d7ee4b65bcbd7e536e0e865 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 f6a5c6ed7542217a721c3b2a6c7c1c647608ee2d..eb7c9bccf96c94a288392e326dfc53e28b0b2fe9 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 4287596af8f30c0d9c6656266e6aead4ee87bbcd..e4c87a54365459099c3c1fbc17f60b2f2f800408 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 c9ad79234d33e1aaa9a5b4f29bf7103f1553854d..4c57665b41f94e913987dd2aa770c5d812e6378e 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))