Class: LogRaider::Interceptor

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

Instance Method Summary collapse

Constructor Details

#initializeInterceptor

Returns a new instance of Interceptor.



5
6
7
# File 'lib/log_raider.rb', line 5

def initialize
  @real_logger = Rails.logger
end

Instance Method Details

#intercept!Object



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

def intercept!
  @real_logger.class_eval do
    def error_with_newrelic_reporting(message)
      return_value = error_without_newrelic_reporting(message)
      NewRelic::Agent.notice_error(Exception.new("From Rails error log: #{message}"))
      return_value
    end

    alias_method :error_without_newrelic_reporting, :error
    alias_method :error, :error_with_newrelic_reporting
  end
end