Commit 6cbaa8aa authored by Christian Theune's avatar Christian Theune

- The SiteErrorLog now allows you to acknowledge exceptions.

parent d0afb92a
......@@ -26,6 +26,11 @@ Zope Changes
Features added
- The SiteErrorLog allows you to acknowledge (or delete) exceptions,
so you can reduce or clear the list without restarting your
Zope server. Additionally the SiteErrorLog is covered by unit tests
now.
- UI improvement for the ZCatalog. The "catalog contents" allow
you to filter the cataloged objects by path now.
......
......@@ -120,6 +120,22 @@ class SiteErrorLog (SimpleItem):
# Exceptions that happen all the time, so we dont need
# to log them. Eventually this should be configured
# through-the-web.
security.declareProtected(use_error_logging, 'forgetEntry')
def forgetEntry(self, id, REQUEST=None):
"""Removes an entry from the error log."""
log = self._getLog()
cleanup_lock.acquire()
i=0
for entry in log:
if entry['id'] == id:
del log[i]
i += 1
cleanup_lock.release()
if REQUEST is not None:
return Globals.MessageDialog(title='Entry removed',
message='Error log entry was removed.',
action='./manage_main',)
_ignored_exceptions = ( 'Unauthorized', 'NotFound', 'Redirect' )
security.declarePrivate('raising')
......
......@@ -17,6 +17,11 @@ $Id$
"""
import SiteErrorLog
from ImageFile import ImageFile
misc_={
'ok.gif': ImageFile('www/ok.gif', globals()),
}
def initialize(context):
context.registerClass(SiteErrorLog.SiteErrorLog,
......
......@@ -61,6 +61,27 @@ class SiteErrorLogTests(unittest.TestCase):
# Now look at the SiteErrorLog, it has one more log entry
self.assertEquals(len(sel_ob.getLogEntries()), previous_log_length+1)
def testForgetException(self):
elog = self.app.error_log
# Create a predictable error
try:
raise AttributeError, "DummyAttribute"
except AttributeError:
info = sys.exc_info()
elog.raising(info)
previous_log_length = len(elog.getLogEntries())
entries = elog.getLogEntries()
self.assertEquals(entries[0]['value'], "DummyAttribute")
# Kick it
elog.forgetEntry(entries[0]['id'])
# Really gone?
self.assertEquals(len(elog.getLogEntries()), previous_log_length-1)
def testIgnoredException(self):
# Grab the Site Error Log
sel_ob = self.app.error_log
......
......@@ -69,6 +69,7 @@ No exceptions logged.
<th align="left">Time</th>
<th align="left">Username (User Id)</th>
<th align="left">Exception</th>
<th></th>
</tr>
<tr tal:repeat="entry entries">
<td valign="top" nowrap="nowrap">
......@@ -88,6 +89,7 @@ No exceptions logged.
Application object has no attribute "zzope"</span>
</a>
</td>
<td><a href="#" tal:attributes="href string:${here/absolute_url}/forgetEntry?id=${entry/id}"><img title="Forget this entry" src="/misc_/SiteErrorLog/ok.gif" border="0"></a></td>
</tr>
</table>
......
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