From 0b02fce5e49e1002eeceebb9cd3e789e5003113a Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 7 Oct 2021 13:05:27 +0200 Subject: [PATCH] jobs: move ActiveJobLogSubscriber out of initializers This is a class of its own, it doesn't need to be in the initializers. --- .../lib/active_job/application_log_subscriber.rb | 2 +- config/initializers/lograge.rb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) rename config/initializers/active_job_log_subscriber.rb => app/lib/active_job/application_log_subscriber.rb (95%) diff --git a/config/initializers/active_job_log_subscriber.rb b/app/lib/active_job/application_log_subscriber.rb similarity index 95% rename from config/initializers/active_job_log_subscriber.rb rename to app/lib/active_job/application_log_subscriber.rb index 854fc5a61..1f7a3361a 100644 --- a/config/initializers/active_job_log_subscriber.rb +++ b/app/lib/active_job/application_log_subscriber.rb @@ -1,7 +1,7 @@ require 'active_job/logging' require 'logstash-event' -class ActiveJobLogSubscriber < ::ActiveJob::LogSubscriber +class ActiveJob::ApplicationLogSubscriber < ::ActiveJob::LogSubscriber def enqueue(event) process_event(event, 'enqueue') end diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index 5a63f1051..6be2a946b 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -1,5 +1,3 @@ -require_relative './active_job_log_subscriber' - Rails.application.configure do config.lograge.formatter = Lograge::Formatters::Logstash.new config.lograge.base_controller_class = ['ActionController::Base', 'Manager::ApplicationController'] @@ -33,6 +31,6 @@ Rails.application.configure do config.lograge.logger = ActiveSupport::Logger.new(Rails.root.join('log', "logstash_#{Rails.env}.log")) if config.lograge.enabled - ActiveJobLogSubscriber.attach_to(:active_job) + ActiveJob::ApplicationLogSubscriber.attach_to(:active_job) end end