Commit 41a447f2 authored by Vincent Pelletier's avatar Vincent Pelletier

Store creation-time traceback in Message class to make it easier to track...

Store creation-time traceback in Message class to make it easier to track where activities come from.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22965 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 907af845
...@@ -63,6 +63,11 @@ except ImportError: ...@@ -63,6 +63,11 @@ except ImportError:
def getTimerService(self): def getTimerService(self):
pass pass
try:
from traceback import format_list, extract_stack
except ImportError:
format_list = extract_stack = None
# minimal IP:Port regexp # minimal IP:Port regexp
NODE_RE = re.compile('^\d+\.\d+\.\d+\.\d+:\d+$') NODE_RE = re.compile('^\d+\.\d+\.\d+\.\d+:\d+$')
...@@ -138,6 +143,13 @@ class Message: ...@@ -138,6 +143,13 @@ class Message:
self.exc_type = None self.exc_type = None
self.exc_value = None self.exc_value = None
self.traceback = None self.traceback = None
if format_list is None:
self.call_traceback = None
else:
# Save current traceback, to make it possible to tell where a message
# was generated.
# Strip last stack entry, since it will always be the same.
self.call_traceback = ''.join(format_list(extract_stack()[:-1]))
self.processing = None self.processing = None
self.user_name = str(_getAuthenticatedUser(self)) self.user_name = str(_getAuthenticatedUser(self))
# Store REQUEST Info # Store REQUEST Info
...@@ -244,8 +256,8 @@ class Message: ...@@ -244,8 +256,8 @@ class Message:
self.is_executed = MESSAGE_NOT_EXECUTED self.is_executed = MESSAGE_NOT_EXECUTED
exc_info = sys.exc_info() exc_info = sys.exc_info()
LOG('ActivityTool', WARNING, LOG('ActivityTool', WARNING,
'Could not call method %s on object %s' % ( 'Could not call method %s on object %s. Activity created at:\n%s' % (
self.method_id, self.object_path), error=exc_info) self.method_id, self.object_path, self.call_traceback), error=exc_info)
# push the error in ZODB error_log # push the error in ZODB error_log
if getattr(activity_tool, 'error_log', None) is not None: if getattr(activity_tool, 'error_log', None) is not None:
activity_tool.error_log.raising(exc_info) activity_tool.error_log.raising(exc_info)
...@@ -277,11 +289,15 @@ Document: %s ...@@ -277,11 +289,15 @@ Document: %s
Method: %s Method: %s
Arguments:%r Arguments:%r
Named Parameters:%r Named Parameters:%r
Created at:
%s
Exception: %s %s Exception: %s %s
%s %s
""" % (activity_tool.email_from_address, user_email, message, """ % (activity_tool.email_from_address, user_email, message,
message, '/'.join(self.object_path), self.method_id, self.args, self.kw, message, '/'.join(self.object_path), self.method_id, self.args, self.kw,
self.call_traceback,
self.exc_type, self.exc_value, self.traceback) self.exc_type, self.exc_value, self.traceback)
try: try:
activity_tool.MailHost.send( mail_text ) activity_tool.MailHost.send( mail_text )
......
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