Posted By

vanne on 02/06/07


Tagged

rails ruby irb


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


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.