We Recommend

Beginning Ruby: From Novice to Professional Beginning Ruby: From Novice to Professional
Beginning Ruby is a thoroughly contemporary guide for every type of reader wanting to learn Ruby, from novice programmers to web developers to Ruby newcomers. It starts by explaining the principles behind object-oriented programming and within a few chapters builds toward creating a genuine Ruby application.


Posted By

vanne on 02/06/07


Tagged

rails ruby irb


Versions (?)


System Wide Console Logging


Published in: Ruby 


URL: http://toolmantim.com/article/2007/2/6/system_wide_script_console_logging

Add this to your ~/.irbrc file and you will have inline logging in the console

  1. script_console_running = ENV.include?('RAILS_ENV') && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
  2. rails_running = ENV.include?('RAILS_ENV') && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
  3. irb_standalone_running = !script_console_running && !rails_running
  4.  
  5. if script_console_running
  6. require 'logger'
  7. Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
  8. end

Report this snippet 

You need to login to post a comment.