Class: Mbeditor::Rack::SilencePingRequest
- Inherits:
-
Object
- Object
- Mbeditor::Rack::SilencePingRequest
- Defined in:
- lib/mbeditor/rack/silence_ping_request.rb
Overview
Silence editor traffic so development logs stay readable, while leaving the initial GET to the engine root visible as a signal that a developer opened Mbeditor.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ SilencePingRequest
constructor
A new instance of SilencePingRequest.
Constructor Details
#initialize(app) ⇒ SilencePingRequest
Returns a new instance of SilencePingRequest.
13 14 15 |
# File 'lib/mbeditor/rack/silence_ping_request.rb', line 13 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mbeditor/rack/silence_ping_request.rb', line 17 def call(env) path = normalized_request_path(env) if root_request?(env, path) @app.call(env) elsif mbeditor_request?(path) || cable_request?(path) || editor_asset_request?(env, path) # Silence to WARN, not the default ERROR. The point is to hide Rails' # own request lines ("Started GET ...", "Completed 200 ..."), which are # INFO — but the default swallows everything below ERROR, including # anything a host app logs from inside authenticate_with or # user_name_callback. Those procs run within this request, so a # developer debugging their own hook with Rails.logger.warn saw # nothing at all and had no way to know why. Rails.logger.silence(::Logger::WARN) { @app.call(env) } else @app.call(env) end end |