Improve logging for proxy publish

Added message type logging during proxy publishing.

Change-Id: Iddbfab0e4dd6e9f5b6d1c3ea5c86029700a2d66d
This commit is contained in:
Stanislav Kudriashev
2014-03-19 14:49:13 +02:00
parent bb6cf4cd2c
commit 4252eb0277
5 changed files with 4 additions and 4 deletions

View File

@@ -152,7 +152,6 @@ class WorkerTaskExecutor(executor.TaskExecutorBase):
def _publish_request(self, request, topic): def _publish_request(self, request, topic):
"""Publish request to a given topic.""" """Publish request to a given topic."""
LOG.debug("Sending request: %s" % request)
try: try:
self._proxy.publish(msg=request, self._proxy.publish(msg=request,
routing_key=topic, routing_key=topic,

View File

@@ -68,7 +68,7 @@ class Message(object):
"""Base class for all message types.""" """Base class for all message types."""
def __str__(self): def __str__(self):
return str(self.to_dict()) return "<%s> %s" % (self.TYPE, self.to_dict())
@abc.abstractmethod @abc.abstractmethod
def to_dict(self): def to_dict(self):

View File

@@ -69,6 +69,7 @@ class Proxy(object):
def publish(self, msg, routing_key, **kwargs): def publish(self, msg, routing_key, **kwargs):
"""Publish message to the named exchange with routing key.""" """Publish message to the named exchange with routing key."""
LOG.debug("Sending %s", msg)
if isinstance(routing_key, six.string_types): if isinstance(routing_key, six.string_types):
routing_keys = [routing_key] routing_keys = [routing_key]
else: else:

View File

@@ -114,7 +114,6 @@ class Server(object):
def _reply(self, reply_to, task_uuid, state=pr.FAILURE, **kwargs): def _reply(self, reply_to, task_uuid, state=pr.FAILURE, **kwargs):
"""Send reply to the `reply_to` queue.""" """Send reply to the `reply_to` queue."""
response = pr.Response(state, **kwargs) response = pr.Response(state, **kwargs)
LOG.debug("Sending reply: %s", response)
try: try:
self._proxy.publish(response, reply_to, correlation_id=task_uuid) self._proxy.publish(response, reply_to, correlation_id=task_uuid)
except Exception: except Exception:

View File

@@ -63,7 +63,8 @@ class TestProtocol(test.TestCase):
def test_str(self): def test_str(self):
request = self.request() request = self.request()
self.assertEqual(str(request), str(request.to_dict())) self.assertEqual(str(request),
"<REQUEST> %s" % self.request_to_dict())
def test_repr(self): def test_repr(self):
expected = '%s:%s' % (self.task.name, self.task_action) expected = '%s:%s' % (self.task.name, self.task_action)