aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-12-27 13:32:40 +0100
committerJosé Valim <jose.valim@gmail.com>2009-12-27 13:32:40 +0100
commit97db79ab3c0af7b6805dcaee99384d96ccb3567d (patch)
treedcb8856f92f3167780134f5f7b7c1a720bbc8e20
parent7e8b7f46bfc086a36db996420fbee93348c5268e (diff)
downloadrails-97db79ab3c0af7b6805dcaee99384d96ccb3567d.tar.gz
rails-97db79ab3c0af7b6805dcaee99384d96ccb3567d.tar.bz2
rails-97db79ab3c0af7b6805dcaee99384d96ccb3567d.zip
Remove ActiveRecord runtime logging from ActionPack and place in ActiveRecord, adding it through config.action_controller.include hook.
-rw-r--r--actionpack/lib/action_controller/metal/logger.rb17
-rw-r--r--actionpack/lib/action_controller/rails.rb1
-rw-r--r--activerecord/lib/active_record.rb1
-rw-r--r--activerecord/lib/active_record/controller_runtime.rb (renamed from actionpack/lib/action_controller/metal/active_record_runtime.rb)4
-rw-r--r--activerecord/lib/active_record/rails.rb3
5 files changed, 21 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/metal/logger.rb b/actionpack/lib/action_controller/metal/logger.rb
index 5d14f6c9c9..e71f77fbb2 100644
--- a/actionpack/lib/action_controller/metal/logger.rb
+++ b/actionpack/lib/action_controller/metal/logger.rb
@@ -30,12 +30,22 @@ module ActionController
end
end
- def cleanup_view_runtime
+ # If you want to remove any time taken into account in :view_runtime
+ # wrongly, you can do it here:
+ #
+ # def cleanup_view_runtime
+ # super - time_taken_in_something_expensive
+ # end
+ #
+ # :api: plugin
+ def cleanup_view_runtime #:nodoc:
yield
end
module ClassMethods
- def log_event(name, before, after, instrumenter_id, payload)
+ # This is the hook invoked by ActiveSupport::Notifications.subscribe.
+ # If you need to log any event, overwrite the method and do it here.
+ def log_event(name, before, after, instrumenter_id, payload) #:nodoc:
if name == :process_action
duration = [(after - before) * 1000, 0.01].max
controller = payload[:controller]
@@ -65,10 +75,11 @@ module ActionController
protected
# A hook which allows logging what happened during controller process action.
+ # :api: plugin
def log_process_action(controller) #:nodoc:
view_runtime = controller.send :view_runtime
logger.info(" View runtime: %.1fms" % view_runtime.to_f) if view_runtime
end
end
end
-end
+end \ No newline at end of file
diff --git a/actionpack/lib/action_controller/rails.rb b/actionpack/lib/action_controller/rails.rb
index e381828ee4..6ebb50887b 100644
--- a/actionpack/lib/action_controller/rails.rb
+++ b/actionpack/lib/action_controller/rails.rb
@@ -1,6 +1,7 @@
module ActionController
class Plugin < Rails::Plugin
plugin_name :action_controller
+ include_modules_in "ActionController::Base"
initializer "action_controller.set_configs" do |app|
app.config.action_controller.each do |k,v|
diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb
index 196b87c0ac..2cfd528f2c 100644
--- a/activerecord/lib/active_record.rb
+++ b/activerecord/lib/active_record.rb
@@ -52,6 +52,7 @@ module ActiveRecord
autoload :Batches
autoload :Calculations
autoload :Callbacks
+ autoload :ControllerRuntime
autoload :DynamicFinderMatch
autoload :DynamicScopeMatch
autoload :Migration
diff --git a/actionpack/lib/action_controller/metal/active_record_runtime.rb b/activerecord/lib/active_record/controller_runtime.rb
index 29f6dcc783..1281901ae8 100644
--- a/actionpack/lib/action_controller/metal/active_record_runtime.rb
+++ b/activerecord/lib/active_record/controller_runtime.rb
@@ -1,5 +1,5 @@
-module ActionController
- module ActiveRecordRuntime
+module ActiveRecord
+ module ControllerRuntime
extend ActiveSupport::Concern
attr_internal :db_runtime
diff --git a/activerecord/lib/active_record/rails.rb b/activerecord/lib/active_record/rails.rb
index e272d4eebc..8b22f869bc 100644
--- a/activerecord/lib/active_record/rails.rb
+++ b/activerecord/lib/active_record/rails.rb
@@ -7,6 +7,9 @@ require "action_controller/rails"
module ActiveRecord
class Plugin < Rails::Plugin
plugin_name :active_record
+ include_modules_in "ActiveRecord::Base"
+
+ config.action_controller.include "ActiveRecord::ControllerRuntime"
initializer "active_record.set_configs" do |app|
app.config.active_record.each do |k,v|