From d04e804b950ddd19786cde80c819e6f359244569 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 10 Dec 2024 15:11:53 -0500 Subject: [PATCH] improvement: don't log field policies unless logging successful policy breakdowns --- lib/ash/error/forbidden/policy.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ash/error/forbidden/policy.ex b/lib/ash/error/forbidden/policy.ex index e72d12107..11be11766 100644 --- a/lib/ash/error/forbidden/policy.ex +++ b/lib/ash/error/forbidden/policy.ex @@ -30,7 +30,14 @@ defmodule Ash.Error.Forbidden.Policy do exception = super(Keyword.put(opts, :policy_breakdown?, Ash.Policy.Info.show_policy_breakdowns?())) - case Ash.Policy.Info.log_policy_breakdowns() do + log_level = + if exception.for_fields do + Ash.Policy.Info.log_successful_policy_breakdowns() + else + Ash.Policy.Info.log_policy_breakdowns() + end + + case log_level do nil -> :ok