aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-04-04 09:17:06 -0400
committereileencodes <eileencodes@gmail.com>2015-04-04 09:21:18 -0400
commit191facc857bb4fb52078fb544c6bc1613a81cc80 (patch)
tree0d5c7606114de1766a754e71d630becefc09552b
parent5abadf1613710c6e6b54e8190b66543861711b8a (diff)
downloadrails-191facc857bb4fb52078fb544c6bc1613a81cc80.tar.gz
rails-191facc857bb4fb52078fb544c6bc1613a81cc80.tar.bz2
rails-191facc857bb4fb52078fb544c6bc1613a81cc80.zip
Don't invoke sql_runtime if logger is not set to info
`sql_runtime` was getting invoked even when the logger was set to fatal. This ensures that does not happen by checking that the logger is set to info level before logging the view runtime. This reduces the number of times `sql_runtime` is called for integration tests with a fatal logger from 6 to 2.
-rw-r--r--activerecord/lib/active_record/log_subscriber.rb3
-rw-r--r--activerecord/lib/active_record/railties/controller_runtime.rb2
2 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb
index 6b26d7be78..af816a278e 100644
--- a/activerecord/lib/active_record/log_subscriber.rb
+++ b/activerecord/lib/active_record/log_subscriber.rb
@@ -31,9 +31,10 @@ module ActiveRecord
end
def sql(event)
- self.class.runtime += event.duration
return unless logger.debug?
+ self.class.runtime += event.duration
+
payload = event.payload
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
diff --git a/activerecord/lib/active_record/railties/controller_runtime.rb b/activerecord/lib/active_record/railties/controller_runtime.rb
index af4840476c..8727e46cb3 100644
--- a/activerecord/lib/active_record/railties/controller_runtime.rb
+++ b/activerecord/lib/active_record/railties/controller_runtime.rb
@@ -19,7 +19,7 @@ module ActiveRecord
end
def cleanup_view_runtime
- if ActiveRecord::Base.connected?
+ if logger.info? && ActiveRecord::Base.connected?
db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
self.db_runtime = (db_runtime || 0) + db_rt_before_render
runtime = super