From b5d175798e15686a4f81e795283b2d1b4226eebd Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 7 May 2021 13:12:25 +0500 Subject: [PATCH] Add debug logging for staging debugging on real data --- .../api/v1/registrant/contacts_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/controllers/api/v1/registrant/contacts_controller.rb b/app/controllers/api/v1/registrant/contacts_controller.rb index ec59ed83f..ce65766e2 100644 --- a/app/controllers/api/v1/registrant/contacts_controller.rb +++ b/app/controllers/api/v1/registrant/contacts_controller.rb @@ -35,6 +35,8 @@ module Api end def update + logger.debug 'Received update request' + logger.debug params contact = current_user_contacts.find_by!(uuid: params[:uuid]) contact.name = params[:name] if params[:name].present? contact.email = params[:email] if params[:email].present? @@ -44,6 +46,8 @@ module Api # https://github.com/rails/rails/pull/13157 reparsed_request_json = ActiveSupport::JSON.decode(request.body.string) .with_indifferent_access + logger.debug 'Reparsed request is following' + logger.debug "#{reparsed_request_json}" disclosed_attributes = reparsed_request_json[:disclosed_attributes] if disclosed_attributes @@ -57,6 +61,8 @@ module Api contact.disclosed_attributes = disclosed_attributes end + logger.debug "Setting.address_processing is set to #{Setting.address_processing}" + if Setting.address_processing && params[:address] address = Contact::Address.new(params[:address][:street], params[:address][:zip], @@ -75,6 +81,7 @@ module Api contact.fax = params[:fax] if params[:fax].present? end + logger.debug "ENV['fax_enabled'] is set to #{ENV['fax_enabled']}" if ENV['fax_enabled'] != 'true' && params[:fax] error_msg = 'Fax processing is disabled and therefore cannot be updated' render json: { errors: [{ address: [error_msg] }] }, status: :bad_request and return @@ -116,6 +123,10 @@ module Api def serialize_contact(contact, links) Serializers::RegistrantApi::Contact.new(contact, links).to_json end + + def logger + Rails.logger + end end end end