mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
5abadf1613
commit
191facc857
2 changed files with 3 additions and 2 deletions
|
@ -31,9 +31,10 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql(event)
|
def sql(event)
|
||||||
self.class.runtime += event.duration
|
|
||||||
return unless logger.debug?
|
return unless logger.debug?
|
||||||
|
|
||||||
|
self.class.runtime += event.duration
|
||||||
|
|
||||||
payload = event.payload
|
payload = event.payload
|
||||||
|
|
||||||
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
|
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
|
||||||
|
|
|
@ -19,7 +19,7 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_view_runtime
|
def cleanup_view_runtime
|
||||||
if ActiveRecord::Base.connected?
|
if logger.info? && ActiveRecord::Base.connected?
|
||||||
db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
|
db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
|
||||||
self.db_runtime = (db_runtime || 0) + db_rt_before_render
|
self.db_runtime = (db_runtime || 0) + db_rt_before_render
|
||||||
runtime = super
|
runtime = super
|
||||||
|
|
Loading…
Reference in a new issue