1class AuditLogger < Logger
 
2
  • Complexity 2 » saikuro
3  def initialize(logdev, error_class, shift_age = 0, shift_size = 1048576)
 
4    super(logdev, shift_age, shift_size)
 
5    @level = ['test', 'cucumber'].include?(Rails.env) ? WARN : INFO
 
6    @error_class = error_class
 
7  end
 
8
  • LongParameterList - has 4 parameters » reek
  • UnusedParameters - has unused parameter 'progname' » reek
  • Complexity 2 » saikuro
 9  def format_message(severity, timestamp, progname, msg)
 
10    puts "#{severity} #{msg}" if self.level == Logger::DEBUG
 
11    "#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
 
12  end
 
  • NilCheck - performs a nil-check » reek
  • Complexity 2 » saikuro
14  def error(msg, exception = nil)
 
15    if exception.nil?
 
16      exception = RuntimeError.new("#{@error_class}: #{msg}")
 
17      exception.set_backtrace msg
 
18    end
 
19    Appsignal.send_exception(exception)
 
 
21    add(ERROR, nil, msg)
 
22  end
 
23end