Commit da930a50 authored by Rajendra Kadam's avatar Rajendra Kadam

Use AppLogger in lib/api/* files

This MR adds AppLogger in some
files in lib/api/* and also
adds changelog for the change

Add changelog

Update changelog

Fix spec failures

Fix title in changelog

Revert change in log cursor
parent ed400ae4
---
title: Use applogger in some files of ee/lib/* and spec files
merge_request: 41056
author: Rajendra Kadam
type: other
...@@ -59,7 +59,7 @@ module Pseudonymizer ...@@ -59,7 +59,7 @@ module Pseudonymizer
pseudonymity_columns) pseudonymity_columns)
) )
rescue => e rescue => e
Rails.logger.error("Failed to export #{table}: #{e}") # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.error("Failed to export #{table}: #{e}")
raise e raise e
end end
...@@ -115,7 +115,7 @@ module Pseudonymizer ...@@ -115,7 +115,7 @@ module Pseudonymizer
file_path = output_filename(table) file_path = output_filename(table)
headers = contents.peek.keys headers = contents.peek.keys
Rails.logger.info "#{self.class.name} writing #{table} to #{file_path}." # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.info "#{self.class.name} writing #{table} to #{file_path}."
Zlib::GzipWriter.open(file_path) do |io| Zlib::GzipWriter.open(file_path) do |io|
csv = CSV.new(io, headers: headers, write_headers: true) csv = CSV.new(io, headers: headers, write_headers: true)
contents.each { |row| csv << row.values } contents.each { |row| csv << row.values }
...@@ -123,7 +123,7 @@ module Pseudonymizer ...@@ -123,7 +123,7 @@ module Pseudonymizer
file_path file_path
rescue StopIteration rescue StopIteration
Rails.logger.info "#{self.class.name} table #{table} is empty." # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.info "#{self.class.name} table #{table} is empty."
nil nil
end end
end end
......
...@@ -33,7 +33,7 @@ module Pseudonymizer ...@@ -33,7 +33,7 @@ module Pseudonymizer
pseudo_extra_fields = pseudonymized - whitelisted pseudo_extra_fields = pseudonymized - whitelisted
pseudo_extra_fields.each do |field| pseudo_extra_fields.each do |field|
Rails.logger.warn("#{self.class.name} extraneous pseudo: #{@table}.#{field} is not whitelisted and will be ignored.") # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn("#{self.class.name} extraneous pseudo: #{@table}.#{field} is not whitelisted and will be ignored.")
end end
pseudonymized & whitelisted pseudonymized & whitelisted
......
...@@ -95,7 +95,7 @@ RSpec.describe Pseudonymizer::Dumper do ...@@ -95,7 +95,7 @@ RSpec.describe Pseudonymizer::Dumper do
} }
} }
expect(Rails.logger).to receive(:warn).with(/extraneous/) expect(Gitlab::AppLogger).to receive(:warn).with(/extraneous/)
pseudo.tables_to_csv pseudo.tables_to_csv
end end
......
...@@ -532,7 +532,7 @@ module API ...@@ -532,7 +532,7 @@ module API
::Gitlab::Tracking.event(category, action.to_s, **args) ::Gitlab::Tracking.event(category, action.to_s, **args)
rescue => error rescue => error
Rails.logger.warn( # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn(
"Tracking event failed for action: #{action}, category: #{category}, message: #{error.message}" "Tracking event failed for action: #{action}, category: #{category}, message: #{error.message}"
) )
end end
......
...@@ -67,7 +67,7 @@ module API ...@@ -67,7 +67,7 @@ module API
result == 'PONG' result == 'PONG'
rescue => e rescue => e
Rails.logger.warn("GitLab: An unexpected error occurred in pinging to Redis: #{e}") # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn("GitLab: An unexpected error occurred in pinging to Redis: #{e}")
false false
end end
......
...@@ -183,7 +183,7 @@ RSpec.describe API::Helpers do ...@@ -183,7 +183,7 @@ RSpec.describe API::Helpers do
end end
it "logs an exception" do it "logs an exception" do
expect(Rails.logger).to receive(:warn).with(/Tracking event failed/) expect(Gitlab::AppLogger).to receive(:warn).with(/Tracking event failed/)
subject.track_event('my_event', category: nil) subject.track_event('my_event', category: nil)
end 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