Last active
January 8, 2016 15:38
-
-
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
This file contains 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
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 |
This file contains 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
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