1class QuietLogger |
|
2 attr_reader :app, :options, :paths |
|
|
4 def initialize(app, options = {}) |
5 @app = app |
|
6 @options = options |
|
7 @paths = Array(options[:paths]) |
|
8 end |
|
|
10 def call(env) |
11 if silence_request?(env) |
|
12 logger.silence { app.call(env) }
|
|
13 else |
|
14 app.call(env)
|
|
15 end |
|
16 end |
|
18 private
|
|
|
20 def silence_request?(env) |
21 paths.any? { |path| path === env['PATH_INFO'] } |
|
22 end |
|
|
24 def logger |
25 Rails.logger |
|
26 end |
|
27end |