[Zodb-checkins] CVS: Packages/ZEO - zrpc2.py:1.1.2.14
jeremy@digicool.com
jeremy@digicool.com
Tue, 22 May 2001 10:15:05 -0400 (EDT)
Update of /cvs-repository/Packages/ZEO
In directory korak.digicool.com:/tmp/cvs-serv6951
Modified Files:
Tag: ZEO-ZRPC-Dev
zrpc2.py
Log Message:
Enhanced several aspects of logging
new_label(): New function that resets the label used with log
messages, useful after a fork.
__repr__(): Added to ClientStorage.
--- Updated File zrpc2.py in package Packages/ZEO --
--- zrpc2.py 2001/05/07 13:11:56 1.1.2.13
+++ zrpc2.py 2001/05/22 14:15:04 1.1.2.14
@@ -41,10 +41,15 @@
REPLY = ".reply" # message name used for replies
ASYNC = 1
-def log(message, level=zeolog.BLATHER, label="zrpc:%s" % os.getpid(),
- error=None):
- zeolog.LOG(label, level, message, error=error)
+_label = "zrpc:%s" % os.getpid()
+def new_label():
+ global _label
+ _label = "zrpc:%s" % os.getpid()
+
+def log(message, level=zeolog.BLATHER, label=None, error=None):
+ zeolog.LOG(label or _label, level, message, error=error)
+
class ZRPCError(POSException.StorageError):
pass
@@ -154,6 +159,9 @@
else:
self.set_caller = 0
+ def __repr__(self):
+ return "<%s %s>" % (self.__class__.__name__, self.addr)
+
def close(self):
if self.closed:
return
@@ -196,7 +204,8 @@
log("call %s%s on %s" % (name, repr(args)[:40], repr(self.obj)),
zeolog.DEBUG)
if not self.check_method(name):
- raise ZRPCError("Invalid method name: %s" % name)
+ raise ZRPCError("Invalid method name: %s on %s" % (name,
+ `self.obj`))
meth = getattr(self.obj, name)
try:
@@ -248,7 +257,7 @@
self.handle_error("Exception raised during decoding")
return
if flags & ASYNC:
- self.handle_error("Asynchronous call raised exception")
+ self.handle_error("Asynchronous call raised exception: %s" % self)
return
if type(err_value) is not types.InstanceType:
err_value = err_type, err_value
@@ -428,9 +437,10 @@
else:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(self.addr)
- except socket.error:
+ except socket.error, msg:
if self.debug:
- log("Failed to connect to server", level=zeolog.DEBUG)
+ log("Failed to connect to server: %s" % msg,
+ level=zeolog.DEBUG)
if repeat:
t = self._wait(t)
else: