Commit d45c861b authored by Gintautas Miliauskas's avatar Gintautas Miliauskas

Updated to use logging instead of zLOG.

parent 5c801ecc
...@@ -13,20 +13,22 @@ ...@@ -13,20 +13,22 @@
############################################################################## ##############################################################################
"""Database objects """Database objects
$Id: DB.py,v 1.75 2004/04/15 16:41:42 jeremy Exp $""" $Id: DB.py,v 1.76 2004/04/17 23:04:52 gintautasm Exp $"""
import cPickle, cStringIO, sys import cPickle, cStringIO, sys
from thread import allocate_lock from thread import allocate_lock
from time import time, ctime from time import time, ctime
import warnings import warnings
import logging
from ZODB.broken import find_global from ZODB.broken import find_global
from ZODB.Connection import Connection from ZODB.Connection import Connection
from ZODB.serialize import referencesf from ZODB.serialize import referencesf
from zLOG import LOG, ERROR
import transaction import transaction
logger = logging.getLogger('zodb.db')
class DB(object): class DB(object):
"""The Object Database """The Object Database
------------------- -------------------
...@@ -601,7 +603,7 @@ class DB(object): ...@@ -601,7 +603,7 @@ class DB(object):
try: try:
self._storage.pack(t, referencesf) self._storage.pack(t, referencesf)
except: except:
LOG("ZODB", ERROR, "packing", error=sys.exc_info()) logger.error("packing", exc_info=True)
raise raise
def setCacheSize(self, v): def setCacheSize(self, v):
......
...@@ -16,13 +16,15 @@ ...@@ -16,13 +16,15 @@
from cStringIO import StringIO from cStringIO import StringIO
from cPickle import Pickler, Unpickler from cPickle import Pickler, Unpickler
from tempfile import TemporaryFile from tempfile import TemporaryFile
import logging
from ZODB.POSException import ExportError from ZODB.POSException import ExportError
from ZODB.utils import p64, u64 from ZODB.utils import p64, u64
from ZODB.serialize import referencesf from ZODB.serialize import referencesf
import zLOG
import sys import sys
logger = logging.getLogger('zodb.ExportImport')
class ExportImport: class ExportImport:
def exportFile(self, oid, f=None): def exportFile(self, oid, f=None):
...@@ -43,9 +45,8 @@ class ExportImport: ...@@ -43,9 +45,8 @@ class ExportImport:
try: try:
p, serial = load(oid, self._version) p, serial = load(oid, self._version)
except: except:
zLOG.LOG("ZODB", zLOG.DEBUG, logger.debug("broken reference for oid %s", repr(oid),
"broken reference for oid %s" % `oid`, exc_info=True)
err=sys.exc_info())
else: else:
referencesf(p, oids) referencesf(p, oids)
f.writelines([oid, p64(len(p)), p]) f.writelines([oid, p64(len(p)), p])
......
...@@ -124,10 +124,11 @@ ...@@ -124,10 +124,11 @@
# record. # record.
import struct import struct
import logging
from ZODB.POSException import POSKeyError from ZODB.POSException import POSKeyError
from ZODB.utils import u64, oid_repr, t32 from ZODB.utils import u64, oid_repr, t32
from zLOG import LOG, ERROR
class CorruptedError(Exception): class CorruptedError(Exception):
pass pass
...@@ -159,6 +160,8 @@ DATA_VERSION_HDR_LEN = 58 ...@@ -159,6 +160,8 @@ DATA_VERSION_HDR_LEN = 58
assert struct.calcsize(TRANS_HDR) == TRANS_HDR_LEN assert struct.calcsize(TRANS_HDR) == TRANS_HDR_LEN
assert struct.calcsize(DATA_HDR) == DATA_HDR_LEN assert struct.calcsize(DATA_HDR) == DATA_HDR_LEN
logger = logging.getLogger('zodb.FileStorage.format')
class FileStorageFormatter(object): class FileStorageFormatter(object):
"""Mixin class that can read and write the low-level format.""" """Mixin class that can read and write the low-level format."""
...@@ -244,7 +247,7 @@ class FileStorageFormatter(object): ...@@ -244,7 +247,7 @@ class FileStorageFormatter(object):
def fail(self, pos, msg, *args): def fail(self, pos, msg, *args):
s = ("%s:%s:" + msg) % ((self._name, pos) + args) s = ("%s:%s:" + msg) % ((self._name, pos) + args)
LOG("FS pack", ERROR, s) logger.error(s)
raise CorruptedError(s) raise CorruptedError(s)
def checkTxn(self, th, pos): def checkTxn(self, th, pos):
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import os import os
import errno import errno
import logging import logging
logger = logging.getLogger("ZODB.lock_file")
try: try:
import fcntl import fcntl
...@@ -23,10 +24,8 @@ except ImportError: ...@@ -23,10 +24,8 @@ except ImportError:
from winlock import LockFile as _LockFile from winlock import LockFile as _LockFile
from winlock import UnlockFile as _UnlockFile from winlock import UnlockFile as _UnlockFile
except ImportError: except ImportError:
import zLOG
def lock_file(file): def lock_file(file):
zLOG.LOG('ZODB', zLOG.INFO, logger.info('No file-locking support on this platform')
'No file-locking support on this platform')
# Windows # Windows
def lock_file(file): def lock_file(file):
...@@ -46,9 +45,8 @@ else: ...@@ -46,9 +45,8 @@ else:
# File is automatically unlocked on close # File is automatically unlocked on close
pass pass
log = logging.getLogger("LockFile")
# This is a better interface to use than the lockfile.lock_file() interface. # This is a better interface to use than the lockfile.lock_file() interface.
# Creating the instance acquires the lock. The file remains open. Calling # Creating the instance acquires the lock. The file remains open. Calling
# close both closes and unlocks the lock file. # close both closes and unlocks the lock file.
...@@ -64,7 +62,7 @@ class LockFile: ...@@ -64,7 +62,7 @@ class LockFile:
try: try:
lock_file(self._fp) lock_file(self._fp)
except: except:
log.exception("Error locking file %s" % path) logger.exception("Error locking file %s", path)
raise raise
print >> self._fp, os.getpid() print >> self._fp, os.getpid()
self._fp.flush() self._fp.flush()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment