Skip to content

Instantly share code, notes, and snippets.

@hmcfletch
Created May 10, 2011 23:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hmcfletch/965592 to your computer and use it in GitHub Desktop.
Allows you to toggle logging to dump to the console and back to the log file
def toggle_console_logging
if ActiveRecord::Base.logger == Rails.logger
l = Logger.new(STDOUT)
l.level = Rails.logger.level
set_logger l and return "console"
else
set_logger Rails.logger and return "log file"
end
end
def set_logger(logger)
ActiveRecord::Base.logger = logger
ActiveRecord::Base.clear_active_connections!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment