Allows you to toggle logging to dump to the console and back to the log file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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