Skip to content

Instantly share code, notes, and snippets.

@dennisfaust
Created December 20, 2013 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennisfaust/8049359 to your computer and use it in GitHub Desktop.
Save dennisfaust/8049359 to your computer and use it in GitHub Desktop.
Formatted log entries from Delayed Job without banging your head...
#
# 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