Skip to content

Instantly share code, notes, and snippets.

@dekart
Created May 4, 2011 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dekart/954862 to your computer and use it in GitHub Desktop.
Save dekart/954862 to your computer and use it in GitHub Desktop.
# Rails on-screen logging
def change_log(stream)
ActiveRecord::Base.logger = Logger.new(stream)
ActiveRecord::Base.clear_active_connections!
end
def show_log
change_log(STDOUT)
reload!
puts "SQL log enabled. All ActiveRecord classes were reloaded."
end
def hide_log
change_log(nil)
reload!
puts "SQL log disabled. All ActiveRecord classes were reloaded."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment