Commit 3c4b7f71 authored by Gintautas Miliauskas's avatar Gintautas Miliauskas

Updated to use logging instead of zLOG.

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