From 7dee9ed9d6e4c82ccb54f831bc6b1ee996d7d29b Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 7 May 2025 17:13:25 -0400 Subject: [PATCH] Log the authenticated user to help track down issues reported by individuals in the logs --- app/controllers/concerns/authentication.rb | 1 + config/environments/development.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/controllers/concerns/authentication.rb b/app/controllers/concerns/authentication.rb index 68e729f02..746d3cda5 100644 --- a/app/controllers/concerns/authentication.rb +++ b/app/controllers/concerns/authentication.rb @@ -59,6 +59,7 @@ module Authentication end def set_current_session(session) + logger.struct " Authorized User##{session.user.id}", authentication: { user: { id: session.user.id } } Current.session = session cookies.signed.permanent[:session_token] = { value: session.signed_id, httponly: true, same_site: :lax } end diff --git a/config/environments/development.rb b/config/environments/development.rb index b929be5c4..74836019d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -77,4 +77,8 @@ Rails.application.configure do config.active_job.queue_adapter = :solid_queue config.solid_queue.connects_to = { database: { writing: :queue } } + + if Rails.root.join("tmp/structured-logging.txt").exist? + config.structured_logging.logger = ActiveSupport::Logger.new("log/structured-development.log") + end end