[Neo-report] r2377 vincent - in /trunk: neo/client/ neo/tests/functional/ tools/

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Oct 30 11:22:11 CEST 2010


Author: vincent
Date: Sat Oct 30 11:22:08 2010
New Revision: 2377

Log:
Move logger initialisation from client.app to Storage.__init__

This makes it easier to control logging in runner (otherwise, would
go to stderr) and functional tests (directed to its own file).

Modified:
    trunk/neo/client/Storage.py
    trunk/neo/client/app.py
    trunk/neo/tests/functional/__init__.py
    trunk/tools/runner

Modified: trunk/neo/client/Storage.py
==============================================================================
--- trunk/neo/client/Storage.py [iso-8859-1] (original)
+++ trunk/neo/client/Storage.py [iso-8859-1] Sat Oct 30 11:22:08 2010
@@ -17,6 +17,7 @@
 
 from ZODB import BaseStorage, ConflictResolution, POSException
 
+from neo import setupLog
 from neo.client.app import Application
 from neo.client.exception import NEOStorageNotFoundError
 from neo.client.exception import NEOStorageDoesNotExistError
@@ -35,9 +36,10 @@ class Storage(BaseStorage.BaseStorage,
     __name__ = 'NEOStorage'
 
     def __init__(self, master_nodes, name, connector=None, read_only=False,
-                 compress=None, **kw):
+                 compress=None, logfile=None, verbose=False, **kw):
         if compress is None:
             compress = True
+        setupLog('CLIENT', filename=logfile, verbose=verbose)
         BaseStorage.BaseStorage.__init__(self, name)
         self._is_read_only = read_only
         self.app = Application(master_nodes, name, connector,

Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Sat Oct 30 11:22:08 2010
@@ -26,9 +26,6 @@ from ZODB.POSException import UndoError,
 from ZODB.ConflictResolution import ResolvedSerial
 from persistent.TimeStamp import TimeStamp
 
-from neo import setupLog
-setupLog('CLIENT', verbose=True)
-
 import neo
 from neo.protocol import NodeTypes, Packets, INVALID_PARTITION, ZERO_TID
 from neo.event import EventManager

Modified: trunk/neo/tests/functional/__init__.py
==============================================================================
--- trunk/neo/tests/functional/__init__.py [iso-8859-1] (original)
+++ trunk/neo/tests/functional/__init__.py [iso-8859-1] Sat Oct 30 11:22:08 2010
@@ -32,8 +32,6 @@ from neo.neoctl.neoctl import NeoCTL, No
 from neo.protocol import ClusterStates, NodeTypes, CellStates
 from neo.util import dump
 from neo.tests import DB_ADMIN, DB_PASSWD
-
-import neo
 from neo.client.Storage import Storage
 
 NEO_MASTER = 'neomaster'
@@ -175,9 +173,6 @@ class NEOCluster(object):
             temp_dir = tempfile.mkdtemp(prefix='neo_')
             print 'Using temp directory %r.' % (temp_dir, )
         self.temp_dir = temp_dir
-        # Setup client logger
-        neo.setupLog(name='CLIENT', filename=os.path.join(self.temp_dir,
-            'client.log'), verbose=self.verbose)
         admin_port = self.__allocatePort()
         self.cluster_name = 'neo_%s' % (random.randint(0, 100), )
         master_node_list = [self.__allocatePort() for i in xrange(master_node_count)]
@@ -329,7 +324,10 @@ class NEOCluster(object):
         return Storage(
             master_nodes=master_nodes,
             name=self.cluster_name,
-            connector='SocketConnector')
+            connector='SocketConnector',
+            logfile=os.path.join(self.temp_dir, 'client.log'),
+            verbose=self.verbose,
+        )
 
     def getZODBConnection(self):
         """ Return a tuple with the database and a connection """

Modified: trunk/tools/runner
==============================================================================
--- trunk/tools/runner [iso-8859-1] (original)
+++ trunk/tools/runner [iso-8859-1] Sat Oct 30 11:22:08 2010
@@ -22,6 +22,7 @@ import tempfile
 import logging
 import time
 import sys
+import neo
 import os
 
 # list of test modules
@@ -90,23 +91,12 @@ ZODB_TEST_MODULES = [
 ]
 
 # configuration 
-CONSOLE_LOG = False
 ATTACH_LOG = False # for ZODB test, only the client side is logged
 LOG_FILE = 'neo.log' 
 
 # override logging configuration to send all messages to a file
-logger = logging.getLogger()
-logger.setLevel(logging.INFO)
-handler = logging.FileHandler(LOG_FILE, 'w+')
-format='[%(module)12s:%(levelname)s:%(lineno)3d] %(message)s'
-formatter = logging.Formatter(format)
-handler.setFormatter(formatter)
-logger.addHandler(handler)
-# enabled console logging if desired
-if CONSOLE_LOG:
-    handler = logging.StreamHandler()
-    handler.setFormatter(formatter)
-    logger.addHandler(handler)
+for logger_name in ('NEO', 'CLIENT'):
+    neo.setupLog(logger_name, filename=LOG_FILE)
 
 class NeoTestRunner(unittest.TestResult):
     """ Custom result class to build report with statistics per module """





More information about the Neo-report mailing list