Skip to content

Instantly share code, notes, and snippets.

@champierre
Last active January 8, 2016 15:38
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 champierre/692b739c4fe875820f7e to your computer and use it in GitHub Desktop.
Save champierre/692b739c4fe875820f7e to your computer and use it in GitHub Desktop.
color-log gem: Colorizes the output of the standard library debug logger. http://blog.champierre.com/1064
Gem::Specification.new do |spec|
spec.name = "color-log"
spec.version = "0.0.1"
spec.authors = ["Junya Ishihara"]
spec.email = ["webmaster@champierre.com"]
spec.summary = "Colorizes the output of the standard library debug logger."
spec.files = ["color-log.rb"]
spec.require_path = "."
end
module ActiveSupport
class Logger < ::Logger
class SimpleFormatter < ::Logger::Formatter
def call_with_debug_colored(severity, timestamp, progname, msg)
if Rails.env.development? && severity == 'DEBUG'
"\033[33m#{call_without_debug_colored(severity, timestamp, progname, msg)}\033[0m"
else
call_without_debug_colored(severity, timestamp, progname, msg)
end
end
alias_method_chain :call, :debug_colored
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment