Skip to content

Instantly share code, notes, and snippets.

@mcmire
Created January 2, 2011 05:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mcmire/762320 to your computer and use it in GitHub Desktop.
Save mcmire/762320 to your computer and use it in GitHub Desktop.
Writing `pp` output to a Rails log
require 'pp'
module Kernel
class LoggerAppender
include Singleton
def <<(msg)
RAILS_DEFAULT_LOGGER.send(:buffer) << (msg || "")
RAILS_DEFAULT_LOGGER.send(:auto_flush)
msg
end
end
# pretty print to Rails log
def ppl(*objs)
logger.debug "\e[33m"
objs.each {|obj|
PP.pp(obj, LoggerAppender.instance)
}
logger.debug "\e[0m"
nil
end
module_function :ppl
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment