提交 191facc8 编写于 作者: E eileencodes

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.
上级 5abadf16
......@@ -31,9 +31,10 @@ def render_bind(attribute)
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])
......
......@@ -19,7 +19,7 @@ def process_action(action, *args)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册