diff --git a/lib/dfe/analytics/railtie.rb b/lib/dfe/analytics/railtie.rb index c174701f..ab87a8f9 100644 --- a/lib/dfe/analytics/railtie.rb +++ b/lib/dfe/analytics/railtie.rb @@ -13,6 +13,12 @@ class Railtie < Rails::Railtie app.config.middleware.use DfE::Analytics::Middleware::RequestIdentity end + initializer 'dfe.analytics.logger' do + ActiveSupport.on_load(:active_job) do + DfE::Analytics::AnalyticsJob.logger = ::Rails.logger.dup.tap { |l| l.level = Logger::WARN } + end + end + config.after_initialize do # internal gem tests will sometimes suppress this so they can test the # init process diff --git a/lib/dfe/analytics/send_events.rb b/lib/dfe/analytics/send_events.rb index 50cd1837..05249c2b 100644 --- a/lib/dfe/analytics/send_events.rb +++ b/lib/dfe/analytics/send_events.rb @@ -13,6 +13,7 @@ def self.do(events) def perform(events) if DfE::Analytics.log_only? + # Use the Rails logger here as the job's logger is set to :warn by default Rails.logger.info("DfE::Analytics: #{events.inspect}") else response = DfE::Analytics.events_client.insert(events, ignore_unknown: true)