~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/trace.py

  • Committer: Martin Pool
  • Date: 2008-09-02 04:34:23 UTC
  • mto: This revision was merged to the branch mainline in revision 3684.
  • Revision ID: mbp@sourcefrog.net-20080902043423-bjnv3wj9fltjvbrj
Merge and update log+ transport decorator

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    Not all operations are logged at this point, if you need an unlogged
34
34
    operation please add a test to the tests of this transport, for the logging
35
35
    of the operation you want logged.
36
 
 
37
 
    Another future enhancement would be to log to bzrlib.trace.mutter when
38
 
    trace+ is used from the command line (or perhaps as well/instead use
39
 
    -Dtransport), to make tracing operations of the entire program easily.
40
36
    """
41
37
 
42
38
    def __init__(self, url, _decorated=None, _from_transport=None):
76
72
 
77
73
    def get(self, relpath):
78
74
        """See Transport.get()."""
79
 
        self._activity.append(('get', relpath))
 
75
        self._trace(('get', relpath))
80
76
        return self._decorated.get(relpath)
81
77
 
82
78
    def get_smart_client(self):
92
88
 
93
89
    def mkdir(self, relpath, mode=None):
94
90
        """See Transport.mkdir()."""
 
91
        self._trace(('mkdir', relpath, mode))
95
92
        return self._decorated.mkdir(relpath, mode)
96
93
 
97
94
    def open_write_stream(self, relpath, mode=None):
104
101
    
105
102
    def put_bytes(self, relpath, bytes, mode=None):
106
103
        """See Transport.put_bytes()."""
107
 
        self._activity.append(('put_bytes', relpath, len(bytes), mode))
 
104
        self._trace(('put_bytes', relpath, len(bytes), mode))
108
105
        return self._decorated.put_bytes(relpath, bytes, mode)
109
106
 
110
107
    def listable(self):
122
119
    def readv(self, relpath, offsets, adjust_for_latency=False,
123
120
        upper_limit=None):
124
121
        """See Transport.readv."""
125
 
        self._activity.append(('readv', relpath, offsets, adjust_for_latency,
 
122
        self._trace(('readv', relpath, offsets, adjust_for_latency,
126
123
            upper_limit))
127
124
        return self._decorated.readv(relpath, offsets, adjust_for_latency,
128
125
            upper_limit)
151
148
        """See Transport.lock_write."""
152
149
        return self._decorated.lock_write(relpath)
153
150
 
 
151
    def _trace(self, operation_tuple):
 
152
        """Record that a transport operation occured.
 
153
 
 
154
        :param operation: Tuple of transport call name and arguments.
 
155
        """
 
156
        self._activity.append(operation_tuple)
 
157
 
154
158
 
155
159
class TraceServer(DecoratorServer):
156
160
    """Server for the TransportTraceDecorator for testing with."""