[Zope3-checkins] CVS: Zope3/lib/python/ZODB - FileStorage.py:1.115

Guido van Rossum guido@python.org
Thu, 19 Dec 2002 17:17:04 -0500


Update of /cvs-repository/Zope3/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv9611

Modified Files:
	FileStorage.py 
Log Message:
Convert to logging module.


=== Zope3/lib/python/ZODB/FileStorage.py 1.114 => 1.115 ===
--- Zope3/lib/python/ZODB/FileStorage.py:1.114	Thu Dec 19 10:39:58 2002
+++ Zope3/lib/python/ZODB/FileStorage.py	Thu Dec 19 17:17:03 2002
@@ -126,6 +126,7 @@
 import time
 from types import StringType
 from struct import pack, unpack
+import logging
 
 try:
     from posix import fsync
@@ -141,8 +142,6 @@
 from ZODB.utils import p64, u64, cp, z64
 from ZODB.fsIndex import fsIndex
 
-from zLOG import LOG, BLATHER, WARNING, ERROR, PANIC
-
 t32 = 1L << 32
 # the struct formats for the headers
 TRANS_HDR = ">8sQcHHH"
@@ -156,22 +155,15 @@
 
 packed_version = 'FS21'
 
-def warn(message, *data):
-    LOG('ZODB FS', WARNING, "%s  warn: %s\n" % (packed_version,
-                                                (message % data)))
-
-def error(message, *data):
-    LOG('ZODB FS', ERROR, "%s ERROR: %s\n" % (packed_version,
-                                              (message % data)))
-
-def nearPanic(message, *data):
-    LOG('ZODB FS', PANIC, "%s ERROR: %s\n" % (packed_version,
-                                              (message % data)))
+logger = logging.getLogger("ZODB.FS.%s" % packed_version)
+
+warn = logger.warn
+error = logger.error
+nearPanic = logger.critical
 
 def panic(message, *data):
-    message = message % data
-    LOG('ZODB FS', PANIC, "%s ERROR: %s\n" % (packed_version, message))
-    raise CorruptedTransactionError(message)
+    logger.critical(message, *data)
+    raise CorruptedTransactionError(message % data)
 
 class FileStorageError(POSException.StorageError):
     pass
@@ -433,7 +425,7 @@
             info = p.load()
         except:
             exc, err = sys.exc_info()[:2]
-            warn("Failed to load database index: %s: %s" % (exc, err))
+            warn("Failed to load database index: %s: %s", exc, err)
             return None
         index = info.get('index')
         vindex = info.get('vindex')
@@ -808,7 +800,7 @@
                 return h2.pnv
             else:
                 warn("restore could not find previous non-version data "
-                     "at %d or %d" % (prev, bp))
+                     "at %d or %d", prev, bp)
                 return None
 
     def supportsUndo(self):
@@ -1931,8 +1923,8 @@
                 if not read_only:
                     warn("It appears that there is invalid data at the end of "
                          "the file, possibly due to a system crash.  %s "
-                         "truncated to recover from bad data at end."
-                         % name)
+                         "truncated to recover from bad data at end.",
+                         name)
                     _truncate(file, name, pos)
                 break
             else:
@@ -2150,8 +2142,8 @@
                               self._file.name, pos)
                     warn("It appears that there is invalid data at the end of "
                          "the file, possibly due to a system crash.  %s "
-                         "truncated to recover from bad data at end."
-                         % self._file.name)
+                         "truncated to recover from bad data at end.",
+                         self._file.name)
                     break
                 else:
                     warn('%s has invalid transaction header at %s',