Commit 4622684e authored by Casey Duncan's avatar Casey Duncan

Added ability for site error log to return the url to the log entry and pass...

Added ability for site error log to return the url to the log entry and pass it to the standard_error_message to make a link from it.
parent 85375a81
...@@ -17,8 +17,8 @@ Aqueduct database adapters, etc. ...@@ -17,8 +17,8 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new This module can also be used as a simple template for implementing new
item types. item types.
$Id: SimpleItem.py,v 1.100 2002/06/12 18:34:17 shane Exp $''' $Id: SimpleItem.py,v 1.101 2002/06/25 20:52:56 caseman Exp $'''
__version__='$Revision: 1.100 $'[11:-2] __version__='$Revision: 1.101 $'[11:-2]
import re, sys, Globals, App.Management, Acquisition, App.Undo import re, sys, Globals, App.Management, Acquisition, App.Undo
import AccessControl.Role, AccessControl.Owned, App.Common import AccessControl.Role, AccessControl.Owned, App.Common
...@@ -159,9 +159,9 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -159,9 +159,9 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
try: try:
log = aq_acquire(self, '__error_log__', containment=1) log = aq_acquire(self, '__error_log__', containment=1)
except AttributeError: except AttributeError:
pass error_log_url = ''
else: else:
log.raising((error_type, error_value, tb)) error_log_url = log.raising((error_type, error_value, tb))
# turn error_type into a string # turn error_type into a string
if hasattr(error_type, '__name__'): if hasattr(error_type, '__name__'):
...@@ -200,7 +200,8 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -200,7 +200,8 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
'error_value': error_value, 'error_value': error_value,
'error_tb': error_tb, 'error_tb': error_tb,
'error_traceback': error_tb, 'error_traceback': error_tb,
'error_message': error_message} 'error_message': error_message,
'error_log_url': error_log_url}
if isinstance(s, HTML): if isinstance(s, HTML):
v = s(client, REQUEST, **kwargs) v = s(client, REQUEST, **kwargs)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Site error log module. """Site error log module.
$Id: SiteErrorLog.py,v 1.7 2002/05/22 15:14:14 shane Exp $ $Id: SiteErrorLog.py,v 1.8 2002/06/25 20:52:56 caseman Exp $
""" """
import os import os
...@@ -125,6 +125,7 @@ class SiteErrorLog (SimpleItem): ...@@ -125,6 +125,7 @@ class SiteErrorLog (SimpleItem):
"""Log an exception. """Log an exception.
Called by SimpleItem's exception handler. Called by SimpleItem's exception handler.
Returns the url to view the error log entry
""" """
try: try:
now = time.time() now = time.time()
...@@ -163,11 +164,12 @@ class SiteErrorLog (SimpleItem): ...@@ -163,11 +164,12 @@ class SiteErrorLog (SimpleItem):
strv = '<unprintable %s object>' % str(type(info[1]).__name__) strv = '<unprintable %s object>' % str(type(info[1]).__name__)
log = self._getLog() log = self._getLog()
entry_id = str(now) + str(random()) # Low chance of collision
log.append({ log.append({
'type': strtype, 'type': strtype,
'value': strv, 'value': strv,
'time': now, 'time': now,
'id': str(now) + str(random()), # Low chance of collision 'id': entry_id,
'tb_text': tb_text, 'tb_text': tb_text,
'tb_html': tb_html, 'tb_html': tb_html,
'username': username, 'username': username,
...@@ -181,6 +183,8 @@ class SiteErrorLog (SimpleItem): ...@@ -181,6 +183,8 @@ class SiteErrorLog (SimpleItem):
del log[:-self.keep_entries] del log[:-self.keep_entries]
finally: finally:
cleanup_lock.release() cleanup_lock.release()
return '%s/showEntry?id=%s' % (self.absolute_url(), entry_id)
except: except:
LOG('SiteError', ERROR, 'Error while logging', LOG('SiteError', ERROR, 'Error while logging',
error=sys.exc_info()) error=sys.exc_info())
...@@ -258,7 +262,6 @@ class SiteErrorLog (SimpleItem): ...@@ -258,7 +262,6 @@ class SiteErrorLog (SimpleItem):
RESPONSE.setHeader('Content-Type', 'text/plain') RESPONSE.setHeader('Content-Type', 'text/plain')
return entry['tb_text'] return entry['tb_text']
Globals.InitializeClass(SiteErrorLog) Globals.InitializeClass(SiteErrorLog)
......
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