Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Silence debugbar routes from the logs
introduce QuietRoutes middleware
- Loading branch information
1 parent
8b262be
commit efe491b
Showing
3 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This middleware silences the Rails logger for requests to the Debugbar routes. | ||
# The poll route can be *very* noisy. | ||
# Rails already does this for the /assets route, see Sprockets::Rails::QuietAssets. | ||
# | ||
# @see Sprockets::Rails::QuietAssets | ||
# @see Rails::Rack::Logger#silence | ||
# | ||
module Debugbar | ||
class QuietRoutes | ||
def initialize(app) | ||
@app = app | ||
@route_regex = %r(\A/{0,2}#{::Debugbar.config.prefix}) | ||
end | ||
|
||
def call(env) | ||
if env['PATH_INFO'] =~ @route_regex | ||
::Rails.logger.silence { @app.call(env) } | ||
else | ||
@app.call(env) | ||
end | ||
end | ||
end | ||
end |