Skip to content

Instantly share code, notes, and snippets.

@skojin
Created October 18, 2012 13:55
Show Gist options
  • Save skojin/3911975 to your computer and use it in GitHub Desktop.
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
class ApplicationController < ActionController::Base
include ColorizedPrint if Rails.env.development?
end
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