Commit 70dcead3 authored by Vincent Pelletier's avatar Vincent Pelletier

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).

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2377 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 61afbbee
......@@ -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,
......
......@@ -26,9 +26,6 @@ from ZODB.POSException import UndoError, StorageTransactionError, ConflictError
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
......
......@@ -32,8 +32,6 @@ from neo.neoctl.neoctl import NeoCTL, NotReadyException
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 """
......
......@@ -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 """
......
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