class AuditLogger < Logger

  def initialize(logdev, error_class, shift_age = 0, shift_size = 1048576)
    super(logdev, shift_age, shift_size)
    @level = ['test', 'cucumber'].include?(Rails.env) ? WARN : INFO
    @error_class = error_class
  end

  def format_message(severity, timestamp, progname, msg)
    puts "#{severity} #{msg}" if self.level == Logger::DEBUG
    "#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
  end

  def error(msg, exception = nil)
    airbrake_params = {
      :error_message => msg.dup,
      :environment_name => Rails.env
    }
    airbrake_params[:error_class] = exception.nil? ? @error_class : exception.class.name
    airbrake_params[:backtrace] = exception.backtrace if ! exception.nil?
    Airbrake.notify(airbrake_params)

    add(ERROR, nil, msg)
  end
end

class AuditLogger < Logger

  def initialize(logdev, error_class, shift_age = 0, shift_size = 1048576)
    super(logdev, shift_age, shift_size)
    @level = ['test', 'cucumber'].include?(Rails.env) ? WARN : INFO
    @error_class = error_class
  end

  def format_message(severity, timestamp, progname, msg)
    puts "#{severity} #{msg}" if self.level == Logger::DEBUG
    "#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
  end

  def error(msg, exception = nil)
    if exception.nil?
      exception = RuntimeError.new("#{@error_class}: #{msg}")
      exception.set_backtrace msg
    end
    NewRelic::Agent.notice_error(exception)

    add(ERROR, nil, msg)
  end
end

Make AuditLogger talk to NewRelic, not Airbrake
Make AuditLogger talk to NewRelic, not Airbrake

We removed Airbrake in 480b55289725eebd3cd15977f229f298c1cbdf7d but didn't stop the logger from talking to it.  We can achieve the same thing with the ``NewRelic::Agent.notice_error`` api (although we can't provide quite as much information).
