diff --git a/config/application.rb b/config/application.rb index b2558f8..90dce41 100644 --- a/config/application.rb +++ b/config/application.rb @@ -3,6 +3,7 @@ require_relative "boot" require_relative "../lib/middleware/custom_static" require_relative "../lib/middleware/dev_host" +require_relative "../lib/middleware/silence_good_job_logging" require "rails/all" @@ -40,6 +41,7 @@ module Websites config.good_job.enable_cron = true config.middleware.insert_before(0, Middleware::DevHost) if Rails.env.development? + config.middleware.insert_before(Rails::Rack::Logger, SilenceGoodJobLogging) config.middleware.insert_before(ActionDispatch::Static, Middleware::CustomStatic, { /^i\.furry\.cool/ => "/furry.cool/images", /^i\.maid\.gay/ => "/maid.gay/images", diff --git a/lib/middleware/silence_good_job_logging.rb b/lib/middleware/silence_good_job_logging.rb new file mode 100644 index 0000000..51fb063 --- /dev/null +++ b/lib/middleware/silence_good_job_logging.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class SilenceGoodJobLogging + def initialize(app) + @app = app + end + + def call(env) + request = Rack::Request.new(env) + host = request.env["websites.dev_host"].presence || request.host + if host == OtherRoutes::ADMIN_DOMAIN && env["PATH_INFO"].start_with?("/jobs") + Rails.logger.silence do + @app.call(env) + end + else + @app.call(env) + end + end +end