From 7462d561825939c77f75555e1898a15f7b729bae Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 2 Jun 2020 16:56:58 +0200 Subject: [PATCH] policies/engine: add more verbosity --- passbook/policies/engine.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/passbook/policies/engine.py b/passbook/policies/engine.py index 143ad6473..c465b5ae5 100644 --- a/passbook/policies/engine.py +++ b/passbook/policies/engine.py @@ -74,9 +74,10 @@ class PolicyEngine: for binding in self._iter_bindings(): self._check_policy_type(binding.policy) policy = binding.policy - cached_policy = cache.get(cache_key(binding, self.request.user), None) + key = cache_key(binding, self.request.user) + cached_policy = cache.get(key, None) if cached_policy and self.use_cache: - LOGGER.debug("P_ENG: Taking result from cache", policy=policy) + LOGGER.debug("P_ENG: Taking result from cache", policy=policy, cache_key=key) self.__cached_policies.append(cached_policy) continue LOGGER.debug("P_ENG: Evaluating policy", policy=policy) @@ -103,7 +104,7 @@ class PolicyEngine: x.result for x in self.__processes if x.result ] for result in process_results + self.__cached_policies: - LOGGER.debug("P_ENG: result", passing=result.passing) + LOGGER.debug("P_ENG: result", passing=result.passing, messages=result.messages) if result.messages: messages += result.messages if not result.passing: