Revert "Do not overwrite AJ logger if it is supplied"

This commit is contained in:
John Hawthorn 2023-12-04 17:32:50 -08:00 committed by GitHub
parent 1544455776
commit 1a4474e7ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 38 deletions

View File

@ -15,7 +15,7 @@ module ActiveJob
end
initializer "active_job.logger" do
ActiveSupport.on_load(:active_job) { self.logger ||= ::Rails.logger }
ActiveSupport.on_load(:active_job) { self.logger = ::Rails.logger }
end
initializer "active_job.custom_serializers" do |app|

View File

@ -1,37 +0,0 @@
# frozen_string_literal: true
require "helper"
require "active_support/testing/isolation"
class RailtieTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation
setup do
require "rails"
rails_logger = Logger.new(nil)
@app ||= Class.new(::Rails::Application) do
def self.name; "AJRailtieTestApp"; end
config.eager_load = false
config.logger = rails_logger
config.active_support.cache_format_version = 7.1
end
end
test "active_job.logger initializer does not overwrite the supplied logger" do
custom_logger = Logger.new(nil)
@app.config.before_initialize do |app|
ActiveSupport.on_load(:active_job) do
self.logger = custom_logger
end
end
require "active_job/railtie"
@app.initialize!
assert_same ActiveJob::Base.logger, custom_logger
end
end