policies/engine: add more verbosity

This commit is contained in:
Jens Langhammer 2020-06-02 16:56:58 +02:00
parent 3f92d1c420
commit 7462d56182
1 changed files with 4 additions and 3 deletions

View File

@ -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: