Commit 66654cac authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Peter Leitzen

Use Applogger in lib/gitlab

parent 2881d5c4
---
title: Use GitLab AppLogger
merge_request: 41261
author: Rajendra Kadam
type: other
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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))
......
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