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.rb10
1 files changed, 10 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..1a4f29e0e2
--- /dev/null
+++ b/actionpack/lib/action_controller/notifications.rb
@@ -0,0 +1,10 @@
+require 'active_support/notifications'
+
+ActiveSupport::Notifications.subscribe(/(read|write|cache|expire|exist)_(fragment|page)\??/) do |*args|
+ event = ActiveSupport::Notifications::Event.new(*args)
+
+ if logger = ActionController::Base.logger
+ human_name = event.name.to_s.humanize
+ logger.info("#{human_name} (%.1fms)" % event.duration)
+ end
+end