Created
December 20, 2013 01:57
-
-
Save dennisfaust/8049359 to your computer and use it in GitHub Desktop.
Formatted log entries from Delayed Job without banging your head...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# config/delayed_job_config.rb | |
# | |
Delayed::Worker.logger = Logger.new(Rails.root.join('log', 'delayed_job.log')) | |
# The base logger is terrible. It only puts what you send. Nothing else. So I had to dig this up and add it. | |
class DJFormatter | |
def call(severity, time, progname, msg) | |
formatted_severity = sprintf("%-5s","#{severity}") | |
"#{Time.now.utc} [#{progname} #{formatted_severity} pid:#{$$}] #{msg.strip}\n" | |
end | |
end | |
Delayed::Worker.logger.formatter= DJFormatter.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment