Merge ~cjwatson/launchpad:py3-request-logging into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 1d6959ea9522af32a6c9bd624ee714f5ac66cb9e
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-request-logging
Merge into: launchpad:master
Diff against target: 30 lines (+4/-4)
1 file modified
lib/lp/services/webapp/publication.py (+4/-4)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+392390@code.launchpad.net

Commit message

Make request logging work on Python 3

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/webapp/publication.py b/lib/lp/services/webapp/publication.py
2index 6324a64..ad4f5c6 100644
3--- a/lib/lp/services/webapp/publication.py
4+++ b/lib/lp/services/webapp/publication.py
5@@ -251,16 +251,16 @@ class LaunchpadBrowserPublication(
6 request._traversal_thread_start = _get_thread_time()
7 threadid = threading.current_thread().ident
8 threadrequestfile = open_for_writing(
9- 'logs/thread-%s.request' % threadid, 'w')
10+ 'logs/thread-%s.request' % threadid, 'wb')
11 try:
12- request_txt = six.text_type(request).encode('UTF-8')
13+ request_txt = six.text_type(request)
14 except Exception:
15 request_txt = 'Exception converting request to string\n\n'
16 try:
17 request_txt += traceback.format_exc()
18 except:
19 request_txt += 'Unable to render traceback!'
20- threadrequestfile.write(request_txt)
21+ threadrequestfile.write(request_txt.encode('UTF-8'))
22 threadrequestfile.close()
23
24 # Tell our custom database adapter that the request has started.
25@@ -873,4 +873,4 @@ def tracelog(request, prefix, msg):
26 """
27 tracelog = ITraceLog(request, None)
28 if tracelog is not None:
29- tracelog.log('%s %s' % (prefix, msg.encode('US-ASCII')))
30+ tracelog.log('%s %s' % (prefix, six.ensure_str(msg, 'US-ASCII')))

Subscribers

People subscribed via source and target branches

to status/vote changes: