Class: RailsExtend::QuietLogs

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_extend/quiet_logs.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ QuietLogs

Returns a new instance of QuietLogs.



4
5
6
7
# File 'lib/rails_extend/quiet_logs.rb', line 4

def initialize(app)
  @app = app
  @assets_regex = %r(\A/{0,2}(#{RailsExtend.config.quiet_logs.join('|')}))
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rails_extend/quiet_logs.rb', line 9

def call(env)
  if env['PATH_INFO'] =~ @assets_regex
    Rails.logger.debug "Silenced: #{env['PATH_INFO']}"
    Rails.logger.silence { @app.call(env) }
  else
    unless Rails.env.development?
      Rails.logger.debug "\e[33m #{'- ~ ' * 40}- \e[0m"
    end
    @app.call(env)
  end
end