Sha256: 3d473c437febe49a383b5dbe61191d4530e3c85ec25feed123d834a6730531e1

Contents?: true

Size: 1.13 KB

Versions: 28

Compression:

Stored size: 1.13 KB

Contents

begin

  STDOUT.sync = true

  def Rails.heroku_stdout_logger
    logger = Logger.new(STDOUT)
    logger.level = Logger.const_get(([ENV['LOG_LEVEL'].to_s.upcase, "INFO"] & %w[DEBUG INFO WARN ERROR FATAL UNKNOWN]).compact.first)
    logger
  end
  
  unless Rails.env.test? 
    case Rails::VERSION::MAJOR
      when 3 then Rails.logger = Rails.application.config.logger = Rails.heroku_stdout_logger
      when 2 then
        # redefine Rails.logger
        def Rails.logger
          @@logger ||= Rails.heroku_stdout_logger
        end
        %w(
          ActiveSupport::Dependencies
          ActiveRecord::Base
          ActionController::Base
          ActionMailer::Base
          ActionView::Base
          ActiveResource::Base
        ).each do |klass_name|
          begin
            klass = Object
            klass_name.split("::").each { |part| klass = klass.const_get(part) }
            klass.logger = Rails.logger
          rescue
          end
        end
        Rails.cache.logger = Rails.logger rescue nil
    end
  end # unless env.test?


rescue Exception => ex

  puts "WARNING: Exception during rails_log_stdout init: #{ex.message}"

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
milia-0.3.15 test/rails_app/vendor/plugins/rails_log_stdout/init.rb
milia-0.3.13 test/rails_app/vendor/plugins/rails_log_stdout/init.rb
milia-0.3.12 test/rails_app/vendor/plugins/rails_log_stdout/init.rb
milia-0.3.11 test/rails_app/vendor/plugins/rails_log_stdout/init.rb
milia-0.3.10 test/rails_app/vendor/plugins/rails_log_stdout/init.rb
milia-0.3.9 test/rails_app/vendor/plugins/rails_log_stdout/init.rb
milia-0.3.8 test/rails_app/vendor/plugins/rails_log_stdout/init.rb
milia-0.3.7 test/rails_app/vendor/plugins/rails_log_stdout/init.rb