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 ...@@ -26,6 +26,11 @@ Zope Changes
Features added 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 - UI improvement for the ZCatalog. The "catalog contents" allow
you to filter the cataloged objects by path now. you to filter the cataloged objects by path now.
......
...@@ -120,6 +120,22 @@ class SiteErrorLog (SimpleItem): ...@@ -120,6 +120,22 @@ class SiteErrorLog (SimpleItem):
# Exceptions that happen all the time, so we dont need # Exceptions that happen all the time, so we dont need
# to log them. Eventually this should be configured # to log them. Eventually this should be configured
# through-the-web. # 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' ) _ignored_exceptions = ( 'Unauthorized', 'NotFound', 'Redirect' )
security.declarePrivate('raising') security.declarePrivate('raising')
......
...@@ -17,6 +17,11 @@ $Id$ ...@@ -17,6 +17,11 @@ $Id$
""" """
import SiteErrorLog import SiteErrorLog
from ImageFile import ImageFile
misc_={
'ok.gif': ImageFile('www/ok.gif', globals()),
}
def initialize(context): def initialize(context):
context.registerClass(SiteErrorLog.SiteErrorLog, context.registerClass(SiteErrorLog.SiteErrorLog,
......
...@@ -61,6 +61,27 @@ class SiteErrorLogTests(unittest.TestCase): ...@@ -61,6 +61,27 @@ class SiteErrorLogTests(unittest.TestCase):
# Now look at the SiteErrorLog, it has one more log entry # Now look at the SiteErrorLog, it has one more log entry
self.assertEquals(len(sel_ob.getLogEntries()), previous_log_length+1) 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): def testIgnoredException(self):
# Grab the Site Error Log # Grab the Site Error Log
sel_ob = self.app.error_log sel_ob = self.app.error_log
......
...@@ -69,6 +69,7 @@ No exceptions logged. ...@@ -69,6 +69,7 @@ No exceptions logged.
<th align="left">Time</th> <th align="left">Time</th>
<th align="left">Username (User Id)</th> <th align="left">Username (User Id)</th>
<th align="left">Exception</th> <th align="left">Exception</th>
<th></th>
</tr> </tr>
<tr tal:repeat="entry entries"> <tr tal:repeat="entry entries">
<td valign="top" nowrap="nowrap"> <td valign="top" nowrap="nowrap">
...@@ -88,6 +89,7 @@ No exceptions logged. ...@@ -88,6 +89,7 @@ No exceptions logged.
Application object has no attribute "zzope"</span> Application object has no attribute "zzope"</span>
</a> </a>
</td> </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> </tr>
</table> </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