Enable verbose query logs in development

This is a new feature in Rails 7. Whenever a query is triggered it not only show you the query (as before), but also tells you (directly in the logs) exactly which line of code was responsible for triggering the query. It's unbelievably useful for debugging and performance work.
This commit is contained in:
Matt-Yorkley
2023-04-28 14:35:16 +01:00
parent 152af5e105
commit 8d9a8d8db5
2 changed files with 5 additions and 0 deletions

View File

@@ -5,6 +5,8 @@
#
# cp .env.development .env.local
VERBOSE_QUERY_LOGS=true
SECRET_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
OFN_REDIS_URL="redis://localhost:6379/1"

View File

@@ -221,6 +221,9 @@ module Openfoodnetwork
config.assets.precompile += ['shared/*']
config.assets.precompile += ['*.jpg', '*.jpeg', '*.png', '*.gif' '*.svg']
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = ENV.fetch("VERBOSE_QUERY_LOGS", false)
# Apply framework defaults. New recommended defaults are successively added with each Rails version and
# include the defaults from previous versions. For more info see:
# https://guides.rubyonrails.org/configuring.html#results-of-config-load-defaults