Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7626

Show
Ignore:
Timestamp:
09/25/07 03:47:37 (1 year ago)
Author:
david
Message:

Added ActiveSupport::BufferedLogger as a duck-typing alternative (albeit with no formatter) to the Ruby Logger, which provides a very nice speed bump (inspired by Ezra's buffered logger) [DHH] Changed the default logger from Ruby's own Logger with the clean_logger extensions to ActiveSupport::BufferedLogger for performance reasons [DHH]. (You can change it back with config.logger = Logger.new(/path/to/log, level).)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r7621 r7626  
    11*SVN* 
     2 
     3* Added ActiveSupport::BufferedLogger as a duck-typing alternative (albeit with no formatter) to the Ruby Logger, which provides a very nice speed bump (inspired by Ezra's buffered logger) [DHH] 
    24 
    35* Object#instance_exec produces fewer garbage methods.  [Mauricio Fernandez] 
  • trunk/activesupport/lib/active_support.rb

    r7473 r7626  
    3030 
    3131require 'active_support/core_ext' 
     32 
    3233require 'active_support/clean_logger' 
     34require 'active_support/buffered_logger' 
     35 
    3336require 'active_support/dependencies' 
    3437require 'active_support/deprecation' 
  • trunk/activesupport/lib/active_support/clean_logger.rb

    r7565 r7626  
    1212# 
    1313#   logger.datetime_format = "%Y-%m-%d" 
     14# 
     15# Note: This logger is deprecated in favor of ActiveSupport::BufferedLogger 
    1416class Logger 
    1517  # Set to false to disable the silencer 
  • trunk/railties/CHANGELOG

    r7623 r7626  
    11*SVN* 
     2 
     3* Changed the default logger from Ruby's own Logger with the clean_logger extensions to ActiveSupport::BufferedLogger for performance reasons [DHH]. (You can change it back with config.logger = Logger.new("/path/to/log", level).) 
    24 
    35* Added a default 422.html page to be rendered when ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved, or ActionController::InvalidAuthenticityToken is raised [DHH] 
  • trunk/railties/lib/dispatcher.rb

    r7475 r7626  
    3939        controller.process(request, response).out(output) 
    4040      end 
    41     rescue Exception => exception # errors from CGI dispatch 
     41    rescue Exception => exception # errors from CGI dispatch 
    4242      failsafe_response(cgi, output, '500 Internal Server Error', exception) do 
    4343        controller ||= (ApplicationController rescue ActionController::Base) 
     
    4545      end 
    4646    ensure 
    47       # Do not give a failsafe response here. 
     47      # Do not give a failsafe response here 
     48      flush_logger 
    4849      reset_after_dispatch 
    4950    end 
     
    166167          RAILS_DEFAULT_LOGGER 
    167168        else 
    168           Logger.new($stderr) 
     169          ActiveSupport::BufferedLogger.new($stderr) 
    169170        end 
     171      end 
     172       
     173      def flush_logger 
     174        RAILS_DEFAULT_LOGGER.flush if defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:flush) 
    170175      end 
    171176  end 
  • trunk/railties/lib/initializer.rb

    r7564 r7626  
    241241      unless logger = configuration.logger 
    242242        begin 
    243           logger = Logger.new(configuration.log_path) 
    244           logger.level = Logger.const_get(configuration.log_level.to_s.upcase) 
    245         rescue StandardError 
    246           logger = Logger.new(STDERR) 
    247           logger.level = Logger::WARN 
     243          logger = ActiveSupport::BufferedLogger.new(configuration.log_path) 
     244          logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase) 
     245          logger.auto_flushing = false if configuration.environment == "production" 
     246        rescue StandardError =>e 
     247          logger = ActiveSupport::BufferedLogger.new(STDERR) 
     248          logger.level = ActiveSupport::BufferedLogger::WARN 
    248249          logger.warn( 
    249250            "Rails Error: Unable to access log file. Please ensure that #{configuration.log_path} exists and is chmod 0666. " +