From 0e958ac683603192cc82e2e4c906c1b5dfa913e8 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 19 Oct 2023 11:36:40 +0200 Subject: [PATCH] amelioration(data_fixer/dossier_champs_missing): ajoute du log --- app/lib/data_fixer/dossier_champs_missing.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/lib/data_fixer/dossier_champs_missing.rb b/app/lib/data_fixer/dossier_champs_missing.rb index f14416b62b9..dbb0ac7261a 100644 --- a/app/lib/data_fixer/dossier_champs_missing.rb +++ b/app/lib/data_fixer/dossier_champs_missing.rb @@ -26,6 +26,7 @@ def apply_fix(dossier) added_champs = added_champs_root + added_champs_in_repetition if !added_champs.empty? dossier.save! + log_champs_added(dossier, added_champs) added_champs.size else 0 @@ -62,4 +63,19 @@ def fix_champs_in_repetition(dossier) end end end + + def log_champs_added(dossier, added_champs) + app_traces = caller.reject { _1.match?(%r{/ruby/.+/gems/}) }.map { _1.sub(Rails.root.to_s, "") } + + payload = { + message: "DataFixer::DossierChampsMissing", + dossier_id: dossier.id, + champs_ids: added_champs.map(&:id).join(",") + caller: log_champs_added + } + + logger = Lograge.logger || Rails.logger + + logger.info payload.to_json + end end