Commit 436e3a5c by Vincent Pelletier

Stop defining and using default "NEO" logger.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2371 71dcc9de-d417-0410-9af5-da40c76e7ee4
1 parent 66486399
......@@ -17,8 +17,7 @@
import logging as logging_std
# default logger
logging = logging_std.getLogger('NEO')
# "logging" is available here only once setupLog has been called.
PREFIX = '%(asctime)s %(levelname)-9s %(name)-10s'
SUFFIX = ' [%(module)14s:%(lineno)3d] %(message)s'
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging
import neo
from neo.node import NodeManager
from neo.event import EventManager
......@@ -68,7 +68,7 @@ class Application(object):
self.server = config.getBind()
self.master_addresses = config.getMasters()
logging.debug('IP address is %s, port is %d', *(self.server))
neo.logging.debug('IP address is %s, port is %d', *(self.server))
# The partition table is initialized after getting the number of
# partitions.
......@@ -105,7 +105,7 @@ class Application(object):
while True:
self.em.poll(1)
except PrimaryFailure:
logging.error('primary master is down')
neo.logging.error('primary master is down')
def connectToPrimary(self):
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging
import neo
from neo.handler import EventHandler
from neo import protocol
......@@ -42,7 +42,7 @@ class AdminEventHandler(EventHandler):
"""This class deals with events for administrating cluster."""
def askPartitionList(self, conn, min_offset, max_offset, uuid):
logging.info("ask partition list from %s to %s for %s" %
neo.logging.info("ask partition list from %s to %s for %s" %
(min_offset, max_offset, dump(uuid)))
app = self.app
# check we have one pt otherwise ask it to PMN
......@@ -61,7 +61,7 @@ class AdminEventHandler(EventHandler):
def askNodeList(self, conn, node_type):
logging.info("ask node list for %s" %(node_type))
neo.logging.info("ask node list for %s" %(node_type))
def node_filter(n):
return n.getType() is node_type
node_list = self.app.nm.getList(node_filter)
......@@ -70,7 +70,7 @@ class AdminEventHandler(EventHandler):
conn.answer(p)
def setNodeState(self, conn, uuid, state, modify_partition_table):
logging.info("set node state for %s-%s" %(dump(uuid), state))
neo.logging.info("set node state for %s-%s" %(dump(uuid), state))
node = self.app.nm.getByUUID(uuid)
if node is None:
raise protocol.ProtocolError('invalid uuid')
......@@ -144,7 +144,7 @@ class MasterEventHandler(EventHandler):
def answerNodeInformation(self, conn):
# XXX: This will no more exists when the initialization module will be
# implemented for factorize code (as done for bootstrap)
logging.debug("answerNodeInformation")
neo.logging.debug("answerNodeInformation")
def notifyPartitionChanges(self, conn, ptid, cell_list):
self.app.pt.update(ptid, cell_list, self.app.nm)
......@@ -176,12 +176,12 @@ class MasterRequestEventHandler(EventHandler):
client_conn.answer(packet)
def answerClusterState(self, conn, state):
logging.info("answerClusterState for a conn")
neo.logging.info("answerClusterState for a conn")
self.app.cluster_state = state
self._answerNeoCTL(conn, Packets.AnswerClusterState(state))
def answerPartitionTable(self, conn, ptid, row_list):
logging.info("answerPartitionTable for a conn")
neo.logging.info("answerPartitionTable for a conn")
client_conn, kw = self.app.dispatcher.pop(conn.getPeerId())
# sent client the partition table
self.app.sendPartitionTable(client_conn)
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging
import neo
from time import sleep
from neo.handler import EventHandler
......@@ -106,7 +106,7 @@ class BootstrapManager(EventHandler):
conn.close()
return
logging.info('connected to a primary master node')
neo.logging.info('connected to a primary master node')
conn.ask(Packets.RequestIdentification(self.node_type,
self.uuid, self.server, self.name))
......@@ -120,7 +120,7 @@ class BootstrapManager(EventHandler):
if self.uuid != your_uuid:
# got an uuid from the primary master
self.uuid = your_uuid
logging.info('Got a new UUID : %s' % dump(self.uuid))
neo.logging.info('Got a new UUID : %s' % dump(self.uuid))
conn.setUUID(uuid)
def getPrimaryConnection(self, connector_handler):
......@@ -128,7 +128,7 @@ class BootstrapManager(EventHandler):
Primary lookup/connection process.
Returns when the connection is made.
"""
logging.info('connecting to a primary master node')
neo.logging.info('connecting to a primary master node')
em, nm = self.app.em, self.app.nm
index = 0
self.current = nm.getMasterList()[0]
......
......@@ -163,7 +163,7 @@ class Storage(BaseStorage.BaseStorage,
def pack(self, t, referencesf, gc=False):
if gc:
logging.warning('Garbage Collection is not available in NEO, '
neo.logging.warning('Garbage Collection is not available in NEO, '
'please use an external tool. Packing without GC.')
self.app.pack(t)
......
......@@ -29,7 +29,7 @@ from persistent.TimeStamp import TimeStamp
from neo import setupLog
setupLog('CLIENT', verbose=True)
from neo import logging
import neo
from neo.protocol import NodeTypes, Packets, INVALID_PARTITION, ZERO_TID
from neo.event import EventManager
from neo.util import makeChecksum as real_makeChecksum, dump
......@@ -317,7 +317,7 @@ class Application(object):
"""
Lookup for the current primary master node
"""
logging.debug('connecting to primary master...')
neo.logging.debug('connecting to primary master...')
ready = False
nm = self.nm
queue = self.local_var.queue
......@@ -349,7 +349,7 @@ class Application(object):
# Query for primary master node
if conn.getConnector() is None:
# This happens if a connection could not be established.
logging.error('Connection to master node %s failed',
neo.logging.error('Connection to master node %s failed',
self.trying_master_node)
continue
try:
......@@ -361,14 +361,15 @@ class Application(object):
# If we reached the primary master node, mark as connected
connected = self.primary_master_node is not None and \
self.primary_master_node is self.trying_master_node
logging.info('Connected to %s' % (self.primary_master_node, ))
neo.logging.info('Connected to %s' % (self.primary_master_node, ))
try:
ready = self.identifyToPrimaryNode(conn)
except ConnectionClosed:
logging.error('Connection to %s lost', self.trying_master_node)
neo.logging.error('Connection to %s lost',
self.trying_master_node)
self.primary_master_node = None
continue
logging.info("Connected and ready")
neo.logging.info("Connected and ready")
return conn
def identifyToPrimaryNode(self, conn):
......@@ -377,7 +378,7 @@ class Application(object):
Might raise ConnectionClosed so that the new primary can be
looked-up again.
"""
logging.info('Initializing from master')
neo.logging.info('Initializing from master')
queue = self.local_var.queue
# Identify to primary master and request initial data
while conn.getUUID() is None:
......@@ -490,7 +491,7 @@ class Application(object):
self.local_var.asked_object = 0
packet = Packets.AskObject(oid, serial, tid)
for cell in cell_list:
logging.debug('trying to load %s at %s before %s from %s',
neo.logging.debug('trying to load %s at %s before %s from %s',
dump(oid), dump(serial), dump(tid), dump(cell.getUUID()))
conn = self.cp.getConnForCell(cell)
if conn is None:
......@@ -506,13 +507,13 @@ class Application(object):
= self.local_var.asked_object
if noid != oid:
# Oops, try with next node
logging.error('got wrong oid %s instead of %s from node %s',
noid, dump(oid), cell.getAddress())
neo.logging.error('got wrong oid %s instead of %s from node ' \
'%s', noid, dump(oid), cell.getAddress())
self.local_var.asked_object = -1
continue
elif checksum != makeChecksum(data):
# Check checksum.
logging.error('wrong checksum from node %s for oid %s',
neo.logging.error('wrong checksum from node %s for oid %s',
cell.getAddress(), dump(oid))
self.local_var.asked_object = -1
continue
......@@ -553,7 +554,7 @@ class Application(object):
self._cache_lock_acquire()
try:
if oid in self.mq_cache:
logging.debug('load oid %s is cached', dump(oid))
neo.logging.debug('load oid %s is cached', dump(oid))
serial, data = self.mq_cache[oid]
return data, serial
finally:
......@@ -577,7 +578,7 @@ class Application(object):
def loadSerial(self, oid, serial):
"""Load an object for a given oid and serial."""
# Do not try in cache as it manages only up-to-date object
logging.debug('loading %s at %s', dump(oid), dump(serial))
neo.logging.debug('loading %s at %s', dump(oid), dump(serial))
return self._load(oid, serial=serial)[0]
......@@ -585,7 +586,7 @@ class Application(object):
def loadBefore(self, oid, tid):
"""Load an object for a given oid before tid committed."""
# Do not try in cache as it manages only up-to-date object
logging.debug('loading %s before %s', dump(oid), dump(tid))
neo.logging.debug('loading %s before %s', dump(oid), dump(tid))
return self._load(oid, tid=tid)
......@@ -611,7 +612,7 @@ class Application(object):
"""Store object."""
if transaction is not self.local_var.txn:
raise StorageTransactionError(self, transaction)
logging.debug('storing oid %s serial %s',
neo.logging.debug('storing oid %s serial %s',
dump(oid), dump(serial))
self._store(oid, serial, data)
return None
......@@ -699,8 +700,9 @@ class Application(object):
new_data = tryToResolveConflict(oid, conflict_serial, serial,
data)
if new_data is not None:
logging.info('Conflict resolution succeed for %r:%r with %r',
dump(oid), dump(serial), dump(conflict_serial))
neo.logging.info('Conflict resolution succeed for ' \
'%r:%r with %r', dump(oid), dump(serial),
dump(conflict_serial))
# Mark this conflict as resolved
resolved_serial_set.update(conflict_serial_dict.pop(oid))
# Try to store again
......@@ -708,10 +710,11 @@ class Application(object):
append(oid)
resolved = True
else:
logging.info('Conflict resolution failed for %r:%r with %r',
dump(oid), dump(serial), dump(conflict_serial))
neo.logging.info('Conflict resolution failed for ' \
'%r:%r with %r', dump(oid), dump(serial),
dump(conflict_serial))
else:
logging.info('Conflict reported for %r:%r with later ' \
neo.logging.info('Conflict reported for %r:%r with later ' \
'transaction %r , cannot resolve conflict.', dump(oid),
dump(serial), dump(conflict_serial))
if not resolved:
......@@ -779,7 +782,7 @@ class Application(object):
local_var.data_list)
add_involved_nodes = self.local_var.involved_nodes.add
for cell in self._getCellListForTID(tid, writable=True):
logging.debug("voting object %s %s", cell.getAddress(),
neo.logging.debug("voting object %s %s", cell.getAddress(),
cell.getState())
conn = self.cp.getConnForCell(cell)
if conn is None:
......@@ -824,7 +827,7 @@ class Application(object):
try:
conn.notify(p)
except:
logging.error('Exception in tpc_abort while notifying ' \
neo.logging.error('Exception in tpc_abort while notifying ' \
'storage node %r of abortion, ignoring.', conn, exc_info=1)
# Just wait for responses to arrive. If any leads to an exception,
......@@ -837,7 +840,7 @@ class Application(object):
try:
_waitAnyMessage()
except:
logging.error('Exception in tpc_abort while handling ' \
neo.logging.error('Exception in tpc_abort while handling ' \
'pending answers, ignoring.', exc_info=1)
self.local_var.clear()
......@@ -906,7 +909,7 @@ class Application(object):
continue
except NEOStorageNotFoundError:
# Tid not found, try with next node
logging.warning('Transaction %s was not found on node %s',
neo.logging.warning('Transaction %s was not found on node %s',
dump(undone_tid), self.nm.getByAddress(conn.getAddress()))
continue
......@@ -1022,7 +1025,7 @@ class Application(object):
update(tid_list)
ordered_tids = list(ordered_tids)
ordered_tids.sort(reverse=True)
logging.debug("UndoLog tids %s", [dump(x) for x in ordered_tids])
neo.logging.debug("UndoLog tids %s", [dump(x) for x in ordered_tids])
# For each transaction, get info
undo_info = []
append = undo_info.append
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging
import neo
from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.pt import MTPartitionTable as PartitionTable
......@@ -43,7 +43,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
if your_uuid is None:
raise ProtocolError('No UUID supplied')
app.uuid = your_uuid
logging.info('Got an UUID: %s', dump(app.uuid))
neo.logging.info('Got an UUID: %s', dump(app.uuid))
node = app.nm.getByAddress(conn.getAddress())
conn.setUUID(uuid)
......@@ -66,7 +66,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
if primary_node is None:
# I don't know such a node. Probably this information
# is old. So ignore it.
logging.warning('Unknown primary master UUID: %s. ' \
neo.logging.warning('Unknown primary master UUID: %s. ' \
'Ignoring.' % dump(primary_uuid))
else:
app.primary_master_node = primary_node
......@@ -94,7 +94,7 @@ class PrimaryNotificationsHandler(BaseHandler):
def connectionClosed(self, conn):
app = self.app
logging.critical("connection to primary master node closed")
neo.logging.critical("connection to primary master node closed")
conn.close()
app.master_conn = None
app.primary_master_node = None
......@@ -104,7 +104,7 @@ class PrimaryNotificationsHandler(BaseHandler):
app = self.app
if app.master_conn is not None:
assert conn is app.master_conn
logging.critical("connection timeout to primary master node " \
neo.logging.critical("connection timeout to primary master node " \
"expired")
BaseHandler.timeoutExpired(self, conn)
......@@ -112,11 +112,11 @@ class PrimaryNotificationsHandler(BaseHandler):
app = self.app
if app.master_conn is not None:
assert conn is app.master_conn
logging.critical("primary master node is broken")
neo.logging.critical("primary master node is broken")
BaseHandler.peerBroken(self, conn)
def stopOperation(self, conn):
logging.critical("master node ask to stop operation")
neo.logging.critical("master node ask to stop operation")
def invalidateObjects(self, conn, tid, oid_list):
app = self.app
......
......@@ -18,7 +18,7 @@
from ZODB.TimeStamp import TimeStamp
from ZODB.POSException import ConflictError
from neo import logging
import neo
from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.protocol import NodeTypes, ProtocolError, LockState
from neo.util import dump
......@@ -74,7 +74,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
local_var = self.app.local_var
object_stored_counter_dict = local_var.object_stored_counter_dict[oid]
if conflicting:
logging.info('%r report a conflict for %r with %r', conn,
neo.logging.info('%r report a conflict for %r with %r', conn,
dump(oid), dump(serial))
conflict_serial_dict = local_var.conflict_serial_dict
if serial in object_stored_counter_dict:
......@@ -138,8 +138,8 @@ class StorageAnswersHandler(AnswerBaseHandler):
raise ConflictError, 'Lock wait timeout for oid %s on %r' % (
dump(oid), conn)
elif status == LockState.GRANTED:
logging.info('Store of oid %s was successful, but after timeout.',
dump(oid))
neo.logging.info('Store of oid %s was successful, but after ' \
'timeout.', dump(oid))
# XXX: Not sure what to do in this case yet, for now do nothing.
else:
# Nobody has the lock, although we asked storage to lock. This
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from threading import Thread, Event
from neo import logging
import neo
class ThreadedPoll(Thread):
"""Polling thread."""
......@@ -24,7 +24,7 @@ class ThreadedPoll(Thread):
# Garbage collector hint:
# Prevent logging module from being garbage-collected as it is needed for
# run method to cleanly exit.
logging = logging
neo = neo
def __init__(self, em, **kw):
Thread.__init__(self, **kw)
......@@ -39,8 +39,8 @@ class ThreadedPoll(Thread):
try:
self.em.poll()
except:
self.logging.error('poll raised, retrying', exc_info=1)
self.logging.debug('Threaded poll stopped')
self.neo.logging.error('poll raised, retrying', exc_info=1)
self.neo.logging.debug('Threaded poll stopped')
def stop(self):
self._stop.set()
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging
import neo
from neo.locking import RLock
from neo.protocol import NodeTypes, Packets
from neo.connection import MTClientConnection, ConnectionClosed
......@@ -61,7 +61,8 @@ class ConnectionPool(object):
# Loop until a connection is obtained.
while True:
logging.debug('trying to connect to %s - %s', node, node.getState())
neo.logging.debug('trying to connect to %s - %s', node,
node.getState())
app.setNodeReady()
conn = MTClientConnection(app.em,
app.storage_event_handler, addr,
......@@ -71,7 +72,7 @@ class ConnectionPool(object):
try:
if conn.getConnector() is None:
# This happens, if a connection could not be established.
logging.error('Connection to %r failed', node)
neo.logging.error('Connection to %r failed', node)
self.notifyFailure(node)
return None
......@@ -85,15 +86,15 @@ class ConnectionPool(object):
app._waitMessage(conn, msg_id,
handler=app.storage_bootstrap_handler)
except ConnectionClosed:
logging.error('Connection to %r failed', node)
neo.logging.error('Connection to %r failed', node)
self.notifyFailure(node)
return None
if app.isNodeReady():
logging.info('Connected %r', node)
neo.logging.info('Connected %r', node)
return conn
else:
logging.info('%r not ready', node)
neo.logging.info('%r not ready', node)
self.notifyFailure(node)
return None
......@@ -108,8 +109,8 @@ class ConnectionPool(object):
not self.app.dispatcher.registered(conn):
del self.connection_dict[conn.getUUID()]
conn.close()
logging.debug('_dropConnections : connection to storage ' \
'node %s:%d closed', *(conn.getAddress()))
neo.logging.debug('_dropConnections : connection to ' \
'storage node %s:%d closed', *(conn.getAddress()))
if len(self.connection_dict) <= self.max_pool_size:
break
finally:
......
......@@ -17,7 +17,7 @@
from time import time
from neo import logging
import neo
from neo.locking import RLock
from neo.protocol import PacketMalformedError, Packets, ParserState
......@@ -62,9 +62,9 @@ def lockCheckWrapper(func):
def wrapper(self, *args, **kw):
if not self._lock._is_owned():
import traceback
logging.warning('%s called on %s instance without being locked.' \
' Stack:\n%s', func.func_code.co_name, self.__class__.__name__,
''.join(traceback.format_stack()))
neo.logging.warning('%s called on %s instance without being ' \
'locked. Stack:\n%s', func.func_code.co_name,
self.__class__.__name__, ''.join(traceback.format_stack()))
# Call anyway
return func(self, *args, **kw)
return wrapper
......@@ -173,7 +173,7 @@ class HandlerSwitcher(object):
if klass and isinstance(packet, klass) or packet.isError():
handler.packetReceived(connection, packet)
else:
logging.error('Unexpected answer %r in %r', packet, connection)
neo.logging.error('Unexpected answer %r in %r', packet, connection)
notification = Packets.Notify('Unexpected answer: %r' % packet)
connection.notify(notification)
connection.abort()
......@@ -181,7 +181,7 @@ class HandlerSwitcher(object):
# apply a pending handler if no more answers are pending
while len(self._pending) > 1 and not self._pending[0][0]:
del self._pending[0]
logging.debug('Apply handler %r on %r', self._pending[0][1],
neo.logging.debug('Apply handler %r on %r', self._pending[0][1],
connection)
if timeout == self._next_timeout:
self._updateNextTimeout()
......@@ -279,12 +279,12 @@ class BaseConnection(object):
if handlers.isPending():
msg_id = handlers.checkTimeout(self, t)
if msg_id is not None:
logging.info('timeout for %r with %r', msg_id, self)
neo.logging.info('timeout for %r with %r', msg_id, self)
self.close()
self.getHandler().timeoutExpired(self)
elif self._timeout.hardExpired(t):
# critical time reach or pong not received, abort
logging.info('timeout with %r', self)
neo.logging.info('timeout with %r', self)
self.notify(Packets.Notify('Timeout'))
self.abort()
self.getHandler().timeoutExpired(self)
......@@ -338,9 +338,9 @@ class BaseConnection(object):
def setHandler(self, handler):
if self._handlers.setHandler(handler):
logging.debug('Set handler %r on %r', handler, self)
neo.logging.debug('Set handler %r on %r', handler, self)
else:
logging.debug('Delay handler %r on %r', handler, self)
neo.logging.debug('Delay handler %r on %r', handler, self)
def getEventManager(self):
return self.em
......@@ -379,7 +379,7 @@ class ListeningConnection(BaseConnection):
"""A listen connection."""
def __init__(self, event_manager, handler, addr, connector, **kw):
logging.debug('listening to %s:%d', *addr)
neo.logging.debug('listening to %s:%d', *addr)
BaseConnection.__init__(self, event_manager, handler,
addr=addr, connector=connector)
self.connector.makeListeningConnection(addr)
......@@ -388,7 +388,7 @@ class ListeningConnection(BaseConnection):
def readable(self):
try:
new_s, addr = self.connector.getNewConnection()
logging.debug('accepted a connection from %s:%d', *addr)
neo.logging.debug('accepted a connection from %s:%d', *addr)
handler = self.getHandler()
new_conn = ServerConnection(self.getEventManager(), handler,
connector=new_s, addr=addr)
......@@ -451,7 +451,7 @@ class Connection(BaseConnection):
return next_id
def close(self):
logging.debug('closing a connector for %r', self)
neo.logging.debug('closing a connector for %r', self)
BaseConnection.close(self)
if self._on_close is not None:
self._on_close()
......@@ -462,7 +462,7 @@ class Connection(BaseConnection):
def abort(self):
"""Abort dealing with this connection."""
logging.debug('aborting a connector for %r', self)
neo.logging.debug('aborting a connector for %r', self)
self.aborted = True
def writable(self):
......@@ -548,16 +548,17 @@ class Connection(BaseConnection):
except ConnectorConnectionClosedException:
# connection resetted by peer, according to the man, this error
# should not occurs but it seems it's false
logging.debug('Connection reset by peer: %r', self.connector)
neo.logging.debug('Connection reset by peer: %r', self.connector)
self._closure()
except:
logging.debug('Unknown connection error: %r', self.connector)
neo.logging.debug('Unknown connection error: %r', self.connector)
self._closure()
# unhandled connector exception
raise
else:
if not data:
logging.debug('Connection %r closed in recv', self.connector)
neo.logging.debug('Connection %r closed in recv',
self.connector)
self._closure()
return
self.read_buf.append(data)
......@@ -574,16 +575,17 @@ class Connection(BaseConnection):
pass
except ConnectorConnectionClosedException:
# connection resetted by peer
logging.debug('Connection reset by peer: %r', self.connector)
neo.logging.debug('Connection reset by peer: %r', self.connector)
self._closure()
except:
logging.debug('Unknown connection error: %r', self.connector)
neo.logging.debug('Unknown connection error: %r', self.connector)
# unhandled connector exception
self._closure()
raise
else:
if not n:
logging.debug('Connection %r closed in send', self.connector)
neo.logging.debug('Connection %r closed in send',
self.connector)
self._closure()
return
if n == len(msg):
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from time import time
from neo import logging
import neo
from neo.epoll import Epoll
from neo.profiling import profiler_decorator
......@@ -184,13 +184,14 @@ class EpollEventManager(object):
self.epoll.modify(fd, fd in self.reader_set, 0)
def log(self):
logging.info('Event Manager:')
logging.info(' Readers: %r', [x for x in self.reader_set])
logging.info(' Writers: %r', [x for x in self.writer_set])
logging.info(' Connections:')
neo.logging.info('Event Manager:')
neo.logging.info(' Readers: %r', [x for x in self.reader_set])
neo.logging.info(' Writers: %r', [x for x in self.writer_set])
neo.logging.info(' Connections:')
pending_set = set(self._pending_processing)
for fd, conn in self.connection_dict.items():
logging.info(' %r: %r (pending=%r)', fd, conn, conn in pending_set)
neo.logging.info(' %r: %r (pending=%r)', fd, conn,
conn in pending_set)
# Default to EpollEventManager.
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging
import neo
from neo.protocol import NodeStates, ErrorCodes, Packets, Errors
from neo.protocol import PacketMalformedError, UnexpectedPacketError, \
BrokenNodeDisallowedError, NotReadyError, ProtocolError
......@@ -40,7 +40,7 @@ class EventHandler(object):
else:
message = 'unexpected packet: %s in %s' % (message,
self.__class__.__name__)
logging.error(message)
neo.logging.error(message)
conn.answer(Errors.ProtocolError(message))
conn.abort()
self.peerBroken(conn)
......@@ -58,7 +58,7 @@ class EventHandler(object):
except UnexpectedPacketError, e:
self.__unexpectedPacket(conn, packet, *e.args)
except PacketMalformedError:
logging.error('malformed packet from %r', conn)
neo.logging.error('malformed packet from %r', conn)
conn.notify(Packets.Notify('Malformed packet: %r' % (packet, )))
conn.abort()
self.peerBroken(conn)
......@@ -82,7 +82,7 @@ class EventHandler(object):
def checkClusterName(self, name):
# raise an exception if the fiven name mismatch the current cluster name
if self.app.name != name:
logging.error('reject an alien cluster')
neo.logging.error('reject an alien cluster')
raise ProtocolError('invalid cluster name')
......@@ -94,32 +94,32 @@ class EventHandler(object):
def connectionStarted(self, conn):
"""Called when a connection is started."""
logging.debug('connection started for %r', conn)
neo.logging.debug('connection started for %r', conn)
def connectionCompleted(self, conn):
"""Called when a connection is completed."""
logging.debug('connection completed for %r', conn)
neo.logging.debug('connection completed for %r', conn)
def connectionFailed(self, conn):
"""Called when a connection failed."""
logging.debug('connection failed for %r', conn)
neo.logging.debug('connection failed for %r', conn)
def connectionAccepted(self, conn):
"""Called when a connection is accepted."""
def timeoutExpired(self, conn):
"""Called when a timeout event occurs."""
logging.debug('timeout expired for %r', conn)
neo.logging.debug('timeout expired for %r', conn)
self.connectionLost(conn, NodeStates.TEMPORARILY_DOWN)
def connectionClosed(self, conn):
"""Called when a connection is closed by the peer."""
logging.debug('connection closed for %r', conn)
neo.logging.debug('connection closed for %r', conn)
self.connectionLost(conn, NodeStates.TEMPORARILY_DOWN)
def peerBroken(self, conn):
"""Called when a peer is broken."""
logging.error('%r is broken', conn)
neo.logging.error('%r is broken', conn)
self.connectionLost(conn, NodeStates.BROKEN)
def connectionLost(self, conn, new_state):
......@@ -131,7 +131,7 @@ class EventHandler(object):
# Packet handlers.
def notify(self, conn, message):
logging.info('notification from %r: %s', conn, message)
neo.logging.info('notification from %r: %s', conn, message)
def requestIdentification(self, conn, node_type,
uuid, address, name):
......@@ -395,16 +395,16 @@ class EventHandler(object):
def protocolError(self, conn, message):
# the connection should have been closed by the remote peer
logging.error('protocol error: %s' % (message,))
neo.logging.error('protocol error: %s' % (message,))
def timeoutError(self, conn, message):
logging.error('timeout error: %s' % (message,))
neo.logging.error('timeout error: %s' % (message,))
def brokenNodeDisallowedError(self, conn, message):
raise RuntimeError, 'broken node disallowed error: %s' % (message,)
def ack(self, conn, message):
logging.debug("no error message : %s" % (message))
neo.logging.debug("no error message : %s" % (message))
# Fetch tables initialization
......
......@@ -15,13 +15,13 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging
import neo
from neo.protocol import PacketMalformedError
from neo.util import dump
from neo.handler import EventHandler
from neo.profiling import profiler_decorator
LOGGER_ENABLED = False
LOGGER_ENABLED = True
class PacketLogger(object):
""" Logger at packet level (for debugging purpose) """
......@@ -37,7 +37,7 @@ class PacketLogger(object):
klass = packet.getType()
uuid = dump(conn.getUUID())
ip, port = conn.getAddress()
logging.debug('#0x%08x %-30s %s %s (%s:%d)', packet.getId(),
neo.logging.debug('#0x%08x %-30s %s %s (%s:%d)', packet.getId(),
packet.__class__.__name__, direction, uuid, ip, port)
# look for custom packet logger
logger = self.packet_dispatch_table.get(klass, None)
......@@ -48,11 +48,11 @@ class PacketLogger(object):
try:
args = packet.decode() or ()
except PacketMalformedError:
logging.warning("Can't decode packet for logging")
neo.logging.warning("Can't decode packet for logging")
return
log_message = logger(conn, *args)
if log_message is not None:
logging.debug('#0x%08x %s', packet.getId(), log_message)
neo.logging.debug('#0x%08x %s', packet.getId(), log_message)
def error(self, conn, code, message):
return "%s (%s)" % (code, message)
......@@ -64,7 +64,7 @@ class PacketLogger(object):
else:
address = '?'
node = (dump(uuid), node_type, address, state)
logging.debug(' ! %s | %8s | %22s | %s' % node)
neo.logging.debug(' ! %s | %8s | %22s | %s' % node)
PACKET_LOGGER = PacketLogger()
if not LOGGER_ENABLED:
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging
import neo
import os, sys
from time import time
......@@ -60,7 +60,7 @@ class Application(object):
for address in config.getMasters():
self.nm.createMaster(address=address)
logging.debug('IP address is %s, port is %d', *(self.server))
neo.logging.debug('IP address is %s, port is %d', *(self.server))
# Partition table
replicas, partitions = config.getReplicas(), config.getPartitions()
......@@ -69,10 +69,10 @@ class Application(object):
if partitions <= 0:
raise RuntimeError, 'partitions must be more than zero'
self.pt = PartitionTable(partitions, replicas)
logging.info('Configuration:')
logging.info('Partitions: %d', partitions)
logging.info('Replicas : %d', replicas)
logging.info('Name : %s', self.name)
neo.logging.info('Configuration:')
neo.logging.info('Partitions: %d', partitions)
neo.logging.info('Replicas : %d', replicas)
neo.logging.info('Name : %s', self.name)
self.listening_conn = None
self.primary = None
......@@ -105,7 +105,7 @@ class Application(object):
try:
self._run()
except:
logging.info('\nPre-mortem informations:')
neo.logging.info('\nPre-mortem informations:')
self.log()
raise
......@@ -143,7 +143,7 @@ class Application(object):
others while attempting to connect to other master nodes at the
same time. Note that storage nodes and client nodes may connect
to self as well as master nodes."""