Class: Distilled::DistilledLogger
- Inherits:
-
Rails::Rack::Logger
- Object
- Rails::Rack::Logger
- Distilled::DistilledLogger
- Defined in:
- lib/distilled.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #determine_log_file(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ DistilledLogger
constructor
A new instance of DistilledLogger.
Constructor Details
#initialize(app, opts = {}) ⇒ DistilledLogger
Returns a new instance of DistilledLogger.
7 8 9 10 11 12 13 |
# File 'lib/distilled.rb', line 7 def initialize(app, opts={}) @app, @filtered_ips = app, opts[:filtered_ips] @nil_logger = Logger.new(nil) @rails_logger = Rails.logger super(app) end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/distilled.rb', line 15 def call(env) logfile = determine_log_file(env) ActiveRecord::Base.logger = logfile ActionController::Base.logger = logfile Rails.logger = logfile # Needs to remain since the logger is cache by ActiveSupport::LogSubscriber class @logger = logfile super end |
#determine_log_file(env) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/distilled.rb', line 28 def determine_log_file(env) request = ActionDispatch::Request.new(env) if @filtered_ips.include?(request.ip) return @nil_logger else return @rails_logger end end |