Rev 4891: Add a -Dhpssthread debug flag to include thread.ident info. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-Dhpss-server
John Arbash Meinel
john at arbash-meinel.com
Fri Dec 11 21:51:49 GMT 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.1-Dhpss-server
------------------------------------------------------------
revno: 4891
revision-id: john at arbash-meinel.com-20091211215144-ml4x175u6mwyhc13
parent: john at arbash-meinel.com-20091211214527-7c7yzh15spl8o8d3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-Dhpss-server
timestamp: Fri 2009-12-11 15:51:44 -0600
message:
Add a -Dhpssthread debug flag to include thread.ident info.
I'm thinking to just go back and always include it. I don't feel like it
adds a lot of clutter, and then we don't have to worry about a new flag.
-------------- next part --------------
=== modified file 'bzrlib/help_topics/en/debug-flags.txt'
--- a/bzrlib/help_topics/en/debug-flags.txt 2009-11-02 17:15:20 +0000
+++ b/bzrlib/help_topics/en/debug-flags.txt 2009-12-11 21:51:44 +0000
@@ -19,6 +19,7 @@
-Dhpss Trace smart protocol requests and responses.
-Dhpssdetail More hpss details.
-Dhpssvfs Traceback on vfs access to Remote objects.
+-Dhpssthread Add thread identifiers to hpss debug messages
-Dhttp Trace http connections, requests and responses.
-Dindex Trace major index operations.
-Dknit Trace knit operations.
=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py 2009-12-11 21:45:27 +0000
+++ b/bzrlib/smart/medium.py 2009-12-11 21:51:44 +0000
@@ -33,7 +33,9 @@
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
import atexit
+import threading
import weakref
+
from bzrlib import (
debug,
errors,
@@ -298,8 +300,13 @@
tstart = osutils.timer_func()
osutils.send_all(self.socket, bytes, self._report_activity)
if 'hpss' in debug.debug_flags:
- trace.mutter('%12s: %d bytes to the socket in %.3fs'
- % ('wrote', len(bytes), osutils.timer_func() - tstart))
+ if 'hpssthread' in debug.debug_flags:
+ ident_str = ' [%s] ' % (threading.currentThread().ident,)
+ else:
+ ident_str = ' '
+ trace.mutter('%12s:%s%d bytes to the socket in %.3fs'
+ % ('wrote', ident_str, len(bytes),
+ osutils.timer_func() - tstart))
class SmartServerPipeStreamMedium(SmartServerStreamMedium):
=== modified file 'bzrlib/smart/protocol.py'
--- a/bzrlib/smart/protocol.py 2009-12-11 21:45:27 +0000
+++ b/bzrlib/smart/protocol.py 2009-12-11 21:51:44 +0000
@@ -1143,7 +1143,6 @@
self.response_sent = False
self._headers = {'Software version': bzrlib.__version__}
if 'hpss' in debug.debug_flags:
- import threading
self._thread_id = threading.currentThread().ident
self._response_start_time = None
@@ -1154,14 +1153,18 @@
t = ''
else:
t = '%5.3fs ' % (time.clock() - self._response_start_time)
+ if 'hpssthread' in debug.debug_flags:
+ t_info = ' [%s] ' % (self._thread_id,)
+ else:
+ t_info = ' '
if extra_bytes is None:
extra = ''
else:
extra = ' ' + repr(extra_bytes[:40])
if len(extra) > 33:
extra = extra[:29] + extra[-1] + '...'
- mutter('%12s: [%s] %s%s%s'
- % (action, self._thread_id, t, message, extra))
+ mutter('%12s:%s%s%s%s'
+ % (action, t_info, t, message, extra))
def send_error(self, exception):
if self.response_sent:
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py 2009-12-11 21:45:27 +0000
+++ b/bzrlib/smart/request.py 2009-12-11 21:51:44 +0000
@@ -298,14 +298,18 @@
t = ''
else:
t = '%5.3fs ' % (osutils.timer_func() - self._request_start_time)
+ if 'hpssthread' in debug.debug_flags:
+ t_info = ' [%s] ' % (self._thread_id,)
+ else:
+ t_info = ' '
if extra_bytes is None:
extra = ''
else:
extra = ' ' + repr(extra_bytes[:40])
if len(extra) > 33:
extra = extra[:29] + extra[-1] + '...'
- trace.mutter('%12s: [%s] %s%s%s'
- % (action, self._thread_id, t, message, extra))
+ trace.mutter('%12s:%s%s%s%s'
+ % (action, t_info, t, message, extra))
def accept_body(self, bytes):
"""Accept body data."""
More information about the bazaar-commits
mailing list