Skip to content

Instantly share code, notes, and snippets.

@samchandra
Created March 6, 2012 14:04
Show Gist options
  • Save samchandra/1986447 to your computer and use it in GitHub Desktop.
Save samchandra/1986447 to your computer and use it in GitHub Desktop.
logger gem usage
require 'logger'
# setup
$LOG = Logger.new("log_file_path")
$LOG.level = Logger::DEBUG
$LOG.debug "What ever you want to log"
# more elaborate, will log all params that
# go through your route/controller, use it
# as helper method
def debug_on
$LOG.debug("#{Time.now} - START")
$LOG.debug("URL: #{request.url}")
$LOG.debug("Params:")
params.each do |k,v|
$LOG.debug("#{k} => #{v}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment