Permalink
Browse files

Soft/Hard AMQP error logging. fixes #3

  • Loading branch information...
1 parent 634ff85 commit 5094955e0b4d716ba46bec0237333e9b26e12b4b @paolo-losi committed Mar 18, 2011
Showing with 11 additions and 6 deletions.
  1. +4 −3 stormed/connection.py
  2. +4 −1 stormed/method/channel.py
  3. +3 −2 stormed/method/connection.py
View
@@ -17,7 +17,7 @@ class Connection(FrameHandler):
heartbeat: int, optional
the requested time interval in seconds for heartbeat frames.
- Connection.on_error callback, when set, is called in case of
+ Connection.on_error callback, when set, is called in case of
"hard" AMQP Error. It receives a ConnectionErrorinstance as argument:
def handle_error(conn_error):
@@ -72,7 +72,7 @@ def connect(self, callback):
def close(self, callback=None):
"""cleanly closes the connection to the server.
-
+
all pending tasks are flushed before connection shutdown"""
if self.status != status.CLOSING:
@@ -141,7 +141,8 @@ def on_closed_stream(self):
try:
self.on_disconnect()
except Exception:
- logger.error('ERROR in on_error() callback', exc_info=True)
+ logger.error('ERROR in on_disconnect() callback',
+ exc_info=True)
def reset(self):
for c in self.channels:
@@ -1,4 +1,4 @@
-from stormed.util import add_method, Enum
+from stormed.util import add_method, Enum, logger
from stormed.serialization import table2str
from stormed.frame import status
from stormed.method.codegen.channel import *
@@ -30,6 +30,9 @@ def handle(self, channel):
raise
channel.reset()
error_code = id2constant.get(self.reply_code, '')
+ logger.warn('Soft Error. channel=%r code=%r. %s', channel.channel_id,
+ error_code,
+ self.reply_text)
if channel.on_error:
try:
channel.on_error(ChannelError(error_code, self.reply_text, method))
@@ -64,9 +64,10 @@ def handle(self, conn):
method = None
conn.reset()
error_code = id2constant.get(self.reply_code, '')
+ logger.warn('Connection Hard Error. code=%r. %s', error_code,
+ self.reply_text)
if conn.on_error:
try:
- conn.on_error(ConnectionError(error_code, self.reply_text, method))
+ conn.on_error(ConnectionError(error_code, self.reply_text, method))
except Exception:
logger.error('ERROR in on_error() callback', exc_info=True)
-

0 comments on commit 5094955

Please sign in to comment.