2009年8月25日火曜日

[Rails][CodeReading] Rails::Initializer (15) initialize_framework_logging

Initializer.process で15番目に呼ばれる initialize_framework_logging メソッド。

def initialize_framework_logging
for framework in ([ :active_record, :action_controller, :action_mailer ] & configuration.frameworks)
framework.to_s.camelize.constantize.const_get("Base").logger ||= Rails.logger
end

ActiveSupport::Dependencies.logger ||= Rails.logger
Rails.cache.logger ||= Rails.logger
end

ActiveRecord, ActionController, ActionMailer (のうちの必要なもの), ActiveSupport::Dependencies, Rails.cache (RAILS_CACHE) のロガーとして Rails.logger を設定しています。Rails.logger は次のメソッド。

def logger
if defined?(RAILS_DEFAULT_LOGGER)
RAILS_DEFAULT_LOGGER
else
nil
end
end


[Rails][CodeReading] Railsの初期化コードを読む (イントロ&目次)

0 件のコメント:

コメントを投稿