Commit 183aa0b5 authored by Julien Muchembled's avatar Julien Muchembled

Always enable packet logger in unit tests

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2683 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e6c0a217
...@@ -30,8 +30,12 @@ class PacketLogger(object): ...@@ -30,8 +30,12 @@ class PacketLogger(object):
_temp = EventHandler(None) _temp = EventHandler(None)
self.packet_dispatch_table = _temp.packet_dispatch_table self.packet_dispatch_table = _temp.packet_dispatch_table
self.error_dispatch_table = _temp.error_dispatch_table self.error_dispatch_table = _temp.error_dispatch_table
self.enable(LOGGER_ENABLED)
def dispatch(self, conn, packet, direction): def enable(self, enabled):
self.dispatch = enabled and self._dispatch or (lambda *args, **kw: None)
def _dispatch(self, conn, packet, direction):
"""This is a helper method to handle various packet types.""" """This is a helper method to handle various packet types."""
# default log message # default log message
klass = packet.getType() klass = packet.getType()
...@@ -70,6 +74,3 @@ class PacketLogger(object): ...@@ -70,6 +74,3 @@ class PacketLogger(object):
neo.lib.logging.debug(' ! %s | %8s | %22s | %s' % node) neo.lib.logging.debug(' ! %s | %8s | %22s | %s' % node)
PACKET_LOGGER = PacketLogger() PACKET_LOGGER = PacketLogger()
if not LOGGER_ENABLED:
# disable logger
PACKET_LOGGER.dispatch = lambda *args, **kw: None
...@@ -26,7 +26,7 @@ import MySQLdb ...@@ -26,7 +26,7 @@ import MySQLdb
import neo import neo
from mock import Mock from mock import Mock
from neo.lib import live_debug, protocol from neo.lib import live_debug, logger, protocol
from neo.lib.protocol import Packets from neo.lib.protocol import Packets
from neo.lib.util import getAddressType from neo.lib.util import getAddressType
from time import time, gmtime, sleep from time import time, gmtime, sleep
...@@ -48,6 +48,7 @@ live_debug.ENABLED = True ...@@ -48,6 +48,7 @@ live_debug.ENABLED = True
live_debug.register() live_debug.register()
# prevent "signal only works in main thread" errors in subprocesses # prevent "signal only works in main thread" errors in subprocesses
live_debug.ENABLED = False live_debug.ENABLED = False
logger.PACKET_LOGGER.enable(True)
def buildUrlFromString(address): def buildUrlFromString(address):
try: try:
......
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