Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
99849d79
Commit
99849d79
authored
Feb 09, 2009
by
Martijn Pieters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge r96315 from trunk: copy entry_id to the event log too
parent
124f946e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
doc/CHANGES.txt
doc/CHANGES.txt
+8
-0
lib/python/Products/SiteErrorLog/SiteErrorLog.py
lib/python/Products/SiteErrorLog/SiteErrorLog.py
+3
-3
lib/python/Products/SiteErrorLog/tests/testSiteErrorLog.py
lib/python/Products/SiteErrorLog/tests/testSiteErrorLog.py
+25
-0
No files found.
doc/CHANGES.txt
View file @
99849d79
...
...
@@ -6,6 +6,14 @@ Zope Changes
Zope 2.10.8 (unreleased)
Features added
- SiteErrorLog now includes the entry id in the information copied to
the event log. This allowes you to correlate a user error report with
the event log after a restart, or let's you find the REQUEST
information in the SiteErrorLog when looking at a traceback in the
event log.
Restructuring
- Added 'InitializeClass' alias in 'App.class_init' to ease migration.
...
...
lib/python/Products/SiteErrorLog/SiteErrorLog.py
View file @
99849d79
...
...
@@ -213,18 +213,18 @@ class SiteErrorLog (SimpleItem):
LOG
.
error
(
'Error while logging'
,
exc_info
=
sys
.
exc_info
())
else
:
if
self
.
copy_to_zlog
:
self
.
_do_copy_to_zlog
(
now
,
strtype
,
str
(
url
),
tb_text
)
self
.
_do_copy_to_zlog
(
now
,
strtype
,
entry_id
,
str
(
url
),
tb_text
)
return
'%s/showEntry?id=%s'
%
(
self
.
absolute_url
(),
entry_id
)
finally
:
info
=
None
def
_do_copy_to_zlog
(
self
,
now
,
strtype
,
url
,
tb_text
):
def
_do_copy_to_zlog
(
self
,
now
,
strtype
,
entry_id
,
url
,
tb_text
):
when
=
_rate_restrict_pool
.
get
(
strtype
,
0
)
if
now
>
when
:
next_when
=
max
(
when
,
now
-
_rate_restrict_burst
*
_rate_restrict_period
)
next_when
+=
_rate_restrict_period
_rate_restrict_pool
[
strtype
]
=
next_when
LOG
.
error
(
'%s
\
n
%s'
%
(
url
,
tb_text
.
rstrip
()))
LOG
.
error
(
'%s
%s
\
n
%s'
%
(
entry_id
,
url
,
tb_text
.
rstrip
()))
security
.
declareProtected
(
use_error_logging
,
'getProperties'
)
def
getProperties
(
self
):
...
...
lib/python/Products/SiteErrorLog/tests/testSiteErrorLog.py
View file @
99849d79
...
...
@@ -14,6 +14,7 @@ import transaction
import
sys
import
unittest
import
logging
class
SiteErrorLogTests
(
unittest
.
TestCase
):
...
...
@@ -27,10 +28,18 @@ class SiteErrorLogTests(unittest.TestCase):
from
Products.SiteErrorLog.SiteErrorLog
import
SiteErrorLog
self
.
app
.
_setObject
(
'error_log'
,
SiteErrorLog
())
self
.
app
.
manage_addDTMLMethod
(
'doc'
,
''
)
self
.
logger
=
logging
.
getLogger
(
'Zope.SiteErrorLog'
)
self
.
log
=
logging
.
handlers
.
BufferingHandler
(
sys
.
maxint
)
self
.
logger
.
addHandler
(
self
.
log
)
self
.
old_level
=
self
.
logger
.
level
self
.
logger
.
setLevel
(
logging
.
ERROR
)
except
:
self
.
tearDown
()
def
tearDown
(
self
):
self
.
logger
.
removeHandler
(
self
.
log
)
self
.
logger
.
setLevel
(
self
.
old_level
)
transaction
.
abort
()
self
.
app
.
_p_jar
.
close
()
...
...
@@ -121,6 +130,22 @@ class SiteErrorLogTests(unittest.TestCase):
# log entries
self
.
assertEquals
(
len
(
sel_ob
.
getLogEntries
()),
previous_log_length
)
def
testEntryID
(
self
):
elog
=
self
.
app
.
error_log
# Create a predictable error
try
:
raise
AttributeError
,
"DummyAttribute"
except
AttributeError
:
info
=
sys
.
exc_info
()
elog
.
raising
(
info
)
entries
=
elog
.
getLogEntries
()
entry_id
=
entries
[
0
][
'id'
]
self
.
assertTrue
(
entry_id
in
self
.
log
.
buffer
[
-
1
].
msg
,
(
entry_id
,
self
.
log
.
buffer
[
-
1
].
msg
))
def
testCleanup
(
self
):
# Need to make sure that the __error_log__ hook gets cleaned up
self
.
app
.
_delObject
(
'error_log'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment