From 95f734e4b873cdd809ec79527db18a91d7d2e0e4 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 10 Feb 2024 20:27:11 +0200 Subject: [PATCH] adjust cloud logs --- config/environments/production.rb | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 57ff50a88..d218ff1fb 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -121,12 +121,26 @@ config.active_record.dump_schema_after_migration = false config.lograge.enabled = true - config.lograge.formatter = Lograge::Formatters::Json.new config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base'] - config.lograge.custom_payload do |controller| - { - fwd: controller.request.ip - } + if ENV['MULTITENANT'] == 'true' + config.lograge.formatter = ->(data) { data.except(:path, :location).to_json } + + config.lograge.custom_payload do |controller| + { + fwd: controller.request.ip.to_s[/\A\d+\.(.*)/, 1], + params: controller.request.params&.slice(:id), + host: controller.request.host, + uid: controller.instance_variable_get(:@current_user).try(:id) + } + end + else + config.lograge.formatter = Lograge::Formatters::Json.new + + config.lograge.custom_payload do |controller| + { + fwd: controller.request.ip + } + end end end