1class JobLogger
 
2
 
3  #
 
4  # Custom logger for ActiveJob classes that adds the Job class name into the log event
 
5  # to make filtering / tracking easier
 
6  #
 
7
  • Complexity 1 » saikuro
8  def initialize(job_class_name, logger = nil)
 
 9    @job_class_name = job_class_name
 
10    @logger = logger
 
11  end
 
  • Complexity 1 » saikuro
13  def debug(msg)
 
14    logger.debug message: msg, job_class: job_class_name
 
15  end
 
  • Complexity 1 » saikuro
17  def info(msg)
 
18    logger.info message: msg, job_class: job_class_name
 
19  end
 
  • Complexity 1 » saikuro
21  def warn(msg)
 
22    logger.warn message: msg, job_class: job_class_name
 
23  end
 
  • Complexity 1 » saikuro
25  def error(msg)
 
26    logger.error message: msg, job_class: job_class_name
 
27  end
 
 
29  private
 
 
31  attr_reader :job_class_name
 
  • Complexity 1 » saikuro
33  def logger
 
34    @logger ||= Rails.logger
 
35  end
 
 
37end