From d193db5543c6aebb449dc23ae3d82f311689d835 Mon Sep 17 00:00:00 2001 From: Joni Lahtinen Date: Tue, 3 Dec 2024 11:05:04 +0200 Subject: [PATCH] Include logger silence from active support --- src/main/ruby/jruby/rack/rails/rails_logger.rb | 15 +++++++++++++++ src/main/ruby/jruby/rack/rails/railtie.rb | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/main/ruby/jruby/rack/rails/rails_logger.rb diff --git a/src/main/ruby/jruby/rack/rails/rails_logger.rb b/src/main/ruby/jruby/rack/rails/rails_logger.rb new file mode 100644 index 00000000..ab1aa29a --- /dev/null +++ b/src/main/ruby/jruby/rack/rails/rails_logger.rb @@ -0,0 +1,15 @@ +require 'active_support/logger_silence' + +module JRuby + module Rack + class RailsLogger < JRuby::Rack::Logger + include ActiveSupport::LoggerSilence + + def info(*args) + return unless info? + + super(*args) + end + end + end +end \ No newline at end of file diff --git a/src/main/ruby/jruby/rack/rails/railtie.rb b/src/main/ruby/jruby/rack/rails/railtie.rb index 1ef002ab..99103ab5 100644 --- a/src/main/ruby/jruby/rack/rails/railtie.rb +++ b/src/main/ruby/jruby/rack/rails/railtie.rb @@ -8,6 +8,7 @@ require 'rails/railtie' require 'pathname' +require 'jruby/rack/rails/rails_logger' module JRuby::Rack class Railtie < ::Rails::Railtie @@ -37,7 +38,9 @@ class Railtie < ::Rails::Railtie initializer 'set_servlet_logger', :before => :initialize_logger do |app| app.config.logger ||= begin - config = app.config; logger = JRuby::Rack.logger + config = app.config + logger = RailsLogger.new + JRuby::Rack.logger = logger log_level = config.log_level || :info logger.level = logger.class.const_get(log_level.to_s.upcase) log_formatter = config.log_formatter if config.respond_to?(:log_formatter) # >= 4.0