Skip to content

Instantly share code, notes, and snippets.

@tokenvolt
Created September 18, 2014 12:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tokenvolt/5f03e3b775ff7a241108 to your computer and use it in GitHub Desktop.
Save tokenvolt/5f03e3b775ff7a241108 to your computer and use it in GitHub Desktop.
Sidekiq Colorful Logger Formatter
Sidekiq.logger.formatter = proc do |severity, time, context, message|
colorized_time = "#{time.utc.iso8601}".colorize(:cyan)
case severity
when 'INFO'
colorized_severity = "#{severity}:".colorize(:green)
"#{colorized_time} #{Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{context} #{colorized_severity} #{message}\n"
when 'ERROR'
colorized_severity = "#{severity}:".colorize(:red)
"#{colorized_time} #{Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{context} #{colorized_severity} #{message}\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment