From: Thomas Jarosch Date: Fri, 29 Jun 2012 08:42:02 +0000 (+0200) Subject: Improved logging during normal operation X-Git-Url: http://developer.intra2net.com/git/?p=imap-fix-internaldate;a=commitdiff_plain;h=28d8aa17082968834f8a2de44fd62212e11050d3 Improved logging during normal operation --- diff --git a/src/caching_data.py b/src/caching_data.py index 64db271..58b3cc9 100644 --- a/src/caching_data.py +++ b/src/caching_data.py @@ -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.""" diff --git a/src/fix_imap_internaldate.py b/src/fix_imap_internaldate.py index 3fe0ee4..672d488 100644 --- a/src/fix_imap_internaldate.py +++ b/src/fix_imap_internaldate.py @@ -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():