Improved logging during normal operation
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 29 Jun 2012 08:42:02 +0000 (10:42 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 29 Jun 2012 08:42:16 +0000 (10:42 +0200)
src/caching_data.py
src/fix_imap_internaldate.py

index 64db271..58b3cc9 100644 (file)
@@ -38,10 +38,10 @@ class CachingData:
             cachefile = open(CACHE_FILENAME, 'rb')
             self.version, self.data = pickle.load(cachefile)
             if(self.version != CACHE_VERSION):
-                logging.warning("Cache file has version %s and the script version is %s.",
+                logging.warning("Cache file has version %s and the script version is %s. Deleting cache.",
                                 self.version, CACHE_VERSION)
                 raise IOError
-            logging.info("Cache version %s", self.version)
+            logging.info("Cache file %s loaded", CACHE_FILENAME)
             logging.debug("%s users found.", len(self.data))
         except IOError:
             self.version = CACHE_VERSION
@@ -55,7 +55,7 @@ class CachingData:
         file_descriptor, tmpname = tempfile.mkstemp(dir=location)
         try:
             cachefile = os.fdopen(file_descriptor, 'wb')
-    
+
             # prepare data based on a save flag
             saved_data = {}
             for user in self.data:
@@ -73,7 +73,7 @@ class CachingData:
                 cachefile.close()
                 os.unlink(tmpname)
                 return
-            
+
             # serialize in file
             pickle.dump((self.version, self.data), cachefile)
             logging.debug("%s users stored.", len(self.data))
@@ -86,7 +86,9 @@ class CachingData:
 
             os.rename(tmpname, CACHE_FILENAME)
         except:
-            os.unlink(tmpname)           
+            os.unlink(tmpname)
+
+        logging.info("Wrote cache file %s", CACHE_FILENAME)
 
     def retrieve_cached_mailbox(self, name, uidvalidity, user):
         """Retrieve a cached mailbox or create it."""
index 3fe0ee4..672d488 100644 (file)
@@ -60,6 +60,7 @@ def main():
     except KeyboardInterrupt:
         logging.info("Script was interrupted by the user.")
 
+    logging.info("All done. Exiting.")
     return
 
 def load_configuration():