Skip to content

Commit 485ec1f

Browse files
authored
Merge pull request reidmorrison#124 from ignisf/account-for-relative-url-root
Take Rails' relative_url_root into account when filtering out Rack asset requests
2 parents acf6448 + b0783c2 commit 485ec1f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/rails_semantic_logger/engine.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ class Engine < ::Rails::Engine
127127

128128
# After any initializers run, but after the gems have been loaded
129129
config.after_initialize do
130+
config = Rails.application.config
131+
130132
# Replace the Bugsnag logger
131-
Bugsnag.configure { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
133+
Bugsnag.configure { |bugsnag_config| bugsnag_config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
132134

133135
# Rails Patches
134136
require("rails_semantic_logger/extensions/action_cable/tagged_logger_proxy") if defined?(::ActionCable)
@@ -174,7 +176,8 @@ class Engine < ::Rails::Engine
174176

175177
# Silence asset logging by applying a filter to the Rails logger itself, not any of the appenders.
176178
if config.rails_semantic_logger.quiet_assets && config.assets.prefix
177-
assets_regex = %r(\A/{0,2}#{config.assets.prefix})
179+
assets_root = config.relative_url_root.to_s + config.assets.prefix
180+
assets_regex = %r(\A/{0,2}#{assets_root})
178181
RailsSemanticLogger::Rack::Logger.logger.filter = ->(log) { log.payload[:path] !~ assets_regex if log.payload }
179182
end
180183

0 commit comments

Comments
 (0)