aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/notifications.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/notifications.rb')
-rw-r--r--actionpack/lib/action_controller/notifications.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/notifications.rb b/actionpack/lib/action_controller/notifications.rb
new file mode 100644
index 0000000000..4ec88193d5
--- /dev/null
+++ b/actionpack/lib/action_controller/notifications.rb
@@ -0,0 +1,8 @@
+require 'active_support/notifications'
+
+ActiveSupport::Notifications.subscribe(/(read|write|cache|expire|exist)_(fragment|page)\??/) do |event|
+ if logger = ActionController::Base.logger
+ human_name = event.name.to_s.humanize
+ logger.info("#{human_name} (%.1fms)" % event.duration)
+ end
+end