From 8d9a8d8db5194b6c94b908a89f619bdd1faa98b6 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 28 Apr 2023 14:35:16 +0100 Subject: [PATCH] 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. --- .env.development | 2 ++ config/application.rb | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.env.development b/.env.development index 15e09487f2..1605f8ffba 100644 --- a/.env.development +++ b/.env.development @@ -5,6 +5,8 @@ # # cp .env.development .env.local +VERBOSE_QUERY_LOGS=true + SECRET_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" OFN_REDIS_URL="redis://localhost:6379/1" diff --git a/config/application.rb b/config/application.rb index 9672715eb4..d042539da4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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