Commit b65ac5ca authored by Jeremy Hylton's avatar Jeremy Hylton

Small improvements to server logging.

Change label to ZSS:pid.  Re-initialize pid every time a StorageServer
is created.  XXX This is sufficient as long as a single process
doesn't create more than one StorageServer instance.  I haven't found
any code that does.

Use log() function for self.log() method of ZEOStorage, so it ends up
sharing the ZSS:pid prefix.
parent bdd67c2d
......@@ -45,9 +45,13 @@ pickler = cPickle.Pickler()
pickler.fast = 1 # Don't use the memo
dump = pickler.dump
def log(message, level=zLOG.INFO, label="StorageServer:%s" % os.getpid(),
error=None):
zLOG.LOG(label, level, message, error=error)
_label = "ZSS"
def set_label():
global _label
_label = "ZSS:%s" % os.getpid()
def log(message, level=zLOG.INFO, label=None, error=None):
zLOG.LOG(label or _label, level, message, error=error)
class StorageServerError(StorageError):
pass
......@@ -68,6 +72,7 @@ class StorageServer:
self.connections = {}
self.dispatcher = Dispatcher(addr, factory=self.new_connection,
reuse_addr=1)
set_label()
def new_connection(self, sock, addr):
c = ManagedServerConnection(sock, addr, ZEOStorage(self), self)
......@@ -144,11 +149,11 @@ class ZEOStorage:
name = self.__class__.__name__
return "<%s %X trans=%s s_trans=%s>" % (name, id(self), tid, stid)
def _log(self, msg, level=zLOG.INFO, error=None, pid=os.getpid()):
def _log(self, msg, level=zLOG.INFO, error=None):
name = getattr(self.__storage, '__name__', None)
if name is None:
name = str(self.__storage)
zLOG.LOG("ZEOStorage:%s:%s" % (pid, name), level, msg, error=error)
zLOG.LOG("%s:%s" % (_label, name), level, msg, error=error)
def setup_delegation(self):
"""Delegate several methods to the storage"""
......@@ -261,7 +266,6 @@ class ZEOStorage:
def new_oids(self, n=100):
"""Return a sequence of n new oids, where n defaults to 100"""
if n <= 0:
# Always return at least one
n = 1
return [self.__storage.new_oid() for i in range(n)]
......
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