diff options
author | José Valim <jose.valim@gmail.com> | 2009-12-30 13:07:48 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-12-30 13:07:48 +0100 |
commit | 4ecdf24bdedfdd1cca1f079259ff2490e2074067 (patch) | |
tree | b31c55a662121d9da270cc47b001b2296f90eedf /activerecord/lib/active_record/rails | |
parent | 97204fc0bc52af8fb6714e6f9fcd414567e0fc1a (diff) | |
download | rails-4ecdf24bdedfdd1cca1f079259ff2490e2074067.tar.gz rails-4ecdf24bdedfdd1cca1f079259ff2490e2074067.tar.bz2 rails-4ecdf24bdedfdd1cca1f079259ff2490e2074067.zip |
Kick AR logging back to life and move ControllerRuntime inside ActiveRecord::Rails.
Diffstat (limited to 'activerecord/lib/active_record/rails')
-rw-r--r-- | activerecord/lib/active_record/rails/controller_runtime.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/rails/controller_runtime.rb b/activerecord/lib/active_record/rails/controller_runtime.rb new file mode 100644 index 0000000000..9ae40c5c8f --- /dev/null +++ b/activerecord/lib/active_record/rails/controller_runtime.rb @@ -0,0 +1,29 @@ +module ActiveRecord + module Rails + module ControllerRuntime + extend ActiveSupport::Concern + + attr_internal :db_runtime + + def cleanup_view_runtime + if ActiveRecord::Base.connected? + db_rt_before_render = ActiveRecord::Base.connection.reset_runtime + runtime = super + db_rt_after_render = ActiveRecord::Base.connection.reset_runtime + self.db_runtime = db_rt_before_render + db_rt_after_render + runtime - db_rt_after_render + else + super + end + end + + module ClassMethods + def log_process_action(controller) + super + db_runtime = controller.send :db_runtime + logger.info(" ActiveRecord runtime: %.1fms" % db_runtime.to_f) if db_runtime + end + end + end + end +end
\ No newline at end of file |