From 01cf5e3a048f7fa1dad19e6df5ea9685f7a88e25 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Tue, 9 Aug 2016 15:27:39 -0500
Subject: [PATCH] Better logging of misses/hits in persistent_dict

---
 pytools/persistent_dict.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/pytools/persistent_dict.py b/pytools/persistent_dict.py
index b07f3bd..513182a 100644
--- a/pytools/persistent_dict.py
+++ b/pytools/persistent_dict.py
@@ -305,6 +305,9 @@ class PersistentDict(object):
                 with open(value_path, "wb") as outf:
                     dump(value, outf, protocol=HIGHEST_PROTOCOL)
 
+                logger.debug("%s: cache store [key=%s]" % (
+                    self.identifier, hexdigest_key))
+
                 # Write key last, so that if the reader below
                 key_path = item_dir_m.sub("key")
                 with open(key_path, "wb") as outf:
@@ -322,6 +325,8 @@ class PersistentDict(object):
         from os.path import join, isdir
         item_dir = join(self.container_dir, hexdigest_key)
         if not isdir(item_dir):
+            logger.debug("%s: cache miss [key=%s]" % (
+                self.identifier, hexdigest_key))
             raise NoSuchEntryError(key)
 
         cleanup_m = CleanupManager()
@@ -360,10 +365,13 @@ class PersistentDict(object):
 
                 if read_key != key:
                     # Key collision, oh well.
-                    logger.debug("key collsion in cache at '%s'"
-                            % self.container_dir)
+                    logger.info("%s: key collsion in cache at '%s'"
+                            % (self.identifier, self.container_dir))
                     raise NoSuchEntryError(key)
 
+                logger.debug("%s: cache hit [key=%s]" % (
+                    self.identifier, hexdigest_key))
+
                 # {{{ load value
 
                 exc = None
-- 
GitLab