Commit f64a44ee authored by dieter's avatar dieter Committed by Kirill Smelkov

*: Do not use logging directly to emit log messages

--------
kirr:

Always use appropriate logger object set up in a module. It was only
ZEO/tests/ConnectionTests.py which was using logging directly even
though corresponding logger object was set up in that module.

Extracted from https://github.com/zopefoundation/ZEO/pull/195
parent d4805a0f
...@@ -80,7 +80,7 @@ class CommonSetupTearDown(StorageTestBase): ...@@ -80,7 +80,7 @@ class CommonSetupTearDown(StorageTestBase):
for i in 1, 2, ... for i in 1, 2, ...
""" """
self.__super_setUp() self.__super_setUp()
logging.info("setUp() %s", self.id()) logger.info("setUp() %s", self.id())
self.file = 'storage_conf' self.file = 'storage_conf'
self._servers = [] self._servers = []
self.caches = [] self.caches = []
...@@ -93,8 +93,8 @@ class CommonSetupTearDown(StorageTestBase): ...@@ -93,8 +93,8 @@ class CommonSetupTearDown(StorageTestBase):
if getattr(self, '_storage', None) is not None: if getattr(self, '_storage', None) is not None:
self._storage.close() self._storage.close()
if hasattr(self._storage, 'cleanup'): if hasattr(self._storage, 'cleanup'):
logging.debug("cleanup storage %s" % logger.debug("cleanup storage %s" %
self._storage.__name__) self._storage.__name__)
self._storage.cleanup() self._storage.cleanup()
for stop in self._servers: for stop in self._servers:
stop() stop()
...@@ -169,8 +169,8 @@ class CommonSetupTearDown(StorageTestBase): ...@@ -169,8 +169,8 @@ class CommonSetupTearDown(StorageTestBase):
def startServer(self, create=1, index=0, read_only=0, ro_svr=0, keep=None, def startServer(self, create=1, index=0, read_only=0, ro_svr=0, keep=None,
path=None, **kw): path=None, **kw):
addr = self.addr[index] addr = self.addr[index]
logging.info("startServer(create=%d, index=%d, read_only=%d) @ %s" % logger.info("startServer(create=%d, index=%d, read_only=%d) @ %s" %
(create, index, read_only, addr)) (create, index, read_only, addr))
if path is None: if path is None:
path = "%s.%d" % (self.file, index) path = "%s.%d" % (self.file, index)
sconf = self.getConfig(path, create, read_only) sconf = self.getConfig(path, create, read_only)
...@@ -184,8 +184,8 @@ class CommonSetupTearDown(StorageTestBase): ...@@ -184,8 +184,8 @@ class CommonSetupTearDown(StorageTestBase):
self.addr[index] = zeoport self.addr[index] = zeoport
def shutdownServer(self, index=0): def shutdownServer(self, index=0):
logging.info("shutdownServer(index=%d) @ %s" % logger.info("shutdownServer(index=%d) @ %s" %
(index, self._servers[index])) (index, self._servers[index]))
stop = self._servers[index] stop = self._servers[index]
if stop is not None: if stop is not None:
stop() stop()
...@@ -851,7 +851,7 @@ class ReconnectionTests(CommonSetupTearDown): ...@@ -851,7 +851,7 @@ class ReconnectionTests(CommonSetupTearDown):
self.pollDown() self.pollDown()
self._storage.verify_result = None self._storage.verify_result = None
perstorage.verify_result = None perstorage.verify_result = None
logging.info('2ALLBEEF') logger.info('2ALLBEEF')
self.startServer(create=0, keep=0) self.startServer(create=0, keep=0)
self.pollUp() self.pollUp()
self.pollUp(storage=perstorage) self.pollUp(storage=perstorage)
...@@ -904,9 +904,9 @@ class ReconnectionTests(CommonSetupTearDown): ...@@ -904,9 +904,9 @@ class ReconnectionTests(CommonSetupTearDown):
oid = self._storage.new_oid() oid = self._storage.new_oid()
obj = MinPO(12) obj = MinPO(12)
self._dostore(oid, data=obj) self._dostore(oid, data=obj)
logging.info("checkReconnection(): About to shutdown server") logger.info("checkReconnection(): About to shutdown server")
self.shutdownServer() self.shutdownServer()
logging.info("checkReconnection(): About to restart server") logger.info("checkReconnection(): About to restart server")
self.startServer(create=0) self.startServer(create=0)
forker.wait_until('reconnect', self._storage.is_connected) forker.wait_until('reconnect', self._storage.is_connected)
oid = self._storage.new_oid() oid = self._storage.new_oid()
...@@ -917,12 +917,12 @@ class ReconnectionTests(CommonSetupTearDown): ...@@ -917,12 +917,12 @@ class ReconnectionTests(CommonSetupTearDown):
break break
except ClientDisconnected: except ClientDisconnected:
# Maybe the exception mess is better now # Maybe the exception mess is better now
logging.info("checkReconnection(): Error after" logger.info("checkReconnection(): Error after"
" server restart; retrying.", exc_info=True) " server restart; retrying.", exc_info=True)
transaction.abort() transaction.abort()
# Give the other thread a chance to run. # Give the other thread a chance to run.
time.sleep(0.1) time.sleep(0.1)
logging.info("checkReconnection(): finished") logger.info("checkReconnection(): finished")
self._storage.close() self._storage.close()
def checkMultipleServers(self): def checkMultipleServers(self):
......
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