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