Commit b720d175 authored by Peter Leitzen's avatar Peter Leitzen

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

Use Applogger in lib/gitlab

See merge request gitlab-org/gitlab!41261
parents 3aefe1d1 66654cac
---
title: Use GitLab AppLogger
merge_request: 41261
author: Rajendra Kadam
type: other
...@@ -248,7 +248,7 @@ module Gitlab ...@@ -248,7 +248,7 @@ module Gitlab
begin begin
custom_options[:cert] = OpenSSL::X509::Certificate.new(custom_options[:cert]) custom_options[:cert] = OpenSSL::X509::Certificate.new(custom_options[:cert])
rescue OpenSSL::X509::CertificateError => e 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
end end
...@@ -256,7 +256,7 @@ module Gitlab ...@@ -256,7 +256,7 @@ module Gitlab
begin begin
custom_options[:key] = OpenSSL::PKey.read(custom_options[:key]) custom_options[:key] = OpenSSL::PKey.read(custom_options[:key])
rescue OpenSSL::PKey::PKeyError => e 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
end end
......
...@@ -218,7 +218,7 @@ module Gitlab ...@@ -218,7 +218,7 @@ module Gitlab
def expire_method_caches(methods) def expire_method_caches(methods)
methods.each do |name| methods.each do |name|
unless cached_methods.include?(name.to_sym) 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 next
end end
......
...@@ -168,7 +168,7 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK ...@@ -168,7 +168,7 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK
end end
it 'logs an error when an invalid key or cert are configured' do 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( stub_ldap_config(
options: { options: {
'host' => 'ldap.example.com', 'host' => 'ldap.example.com',
...@@ -183,7 +183,7 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK ...@@ -183,7 +183,7 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK
config.adapter_options 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 end
context 'when verify_certificates is enabled' do context 'when verify_certificates is enabled' do
......
...@@ -302,7 +302,7 @@ RSpec.describe Gitlab::RepositoryCacheAdapter do ...@@ -302,7 +302,7 @@ RSpec.describe Gitlab::RepositoryCacheAdapter do
it 'does not expire caches for non-existent methods' do it 'does not expire caches for non-existent methods' do
expect(cache).not_to receive(:expire).with(:nonexistent) 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")) receive(:error).with("Requested to expire non-existent method 'nonexistent' for Repository"))
repository.expire_method_caches(%i(nonexistent)) 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