Created
October 18, 2012 13:55
-
-
Save skojin/3911975 to your computer and use it in GitHub Desktop.
make p and puts in controller actions output into console and color it to make more bright
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
class ApplicationController < ActionController::Base | |
include ColorizedPrint if Rails.env.development? | |
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 ColorizedPrint | |
def puts(arg) | |
Rails.logger.debug colorize(arg) | |
end | |
def p(arg) | |
Rails.logger.debug colorize(arg.inspect) | |
end | |
private | |
def colorize(text) | |
"\e[32;40;1m#{text}\e[0m" | |
# color reference http://kpumuk.info/ruby-on-rails/colorizing-console-ruby-script-output/ | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment