~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/log.py

  • Committer: Martin Pool
  • Date: 2009-07-10 06:46:10 UTC
  • mto: (4525.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4526.
  • Revision ID: mbp@sourcefrog.net-20090710064610-sqviksbqp5i34sw2
Rename to per_interrepository

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
26
26
import types
27
27
 
28
28
from bzrlib.trace import mutter
29
 
from bzrlib.transport import decorator
30
 
 
31
 
 
32
 
class TransportLogDecorator(decorator.TransportDecorator):
 
29
from bzrlib.transport.decorator import (
 
30
    TransportDecorator,
 
31
    )
 
32
from bzrlib.transport.trace import (
 
33
    DecoratorServer,
 
34
    TransportTraceDecorator,
 
35
    )
 
36
 
 
37
 
 
38
 
 
39
 
 
40
class TransportLogDecorator(TransportDecorator):
33
41
    """Decorator for Transports that logs interesting operations to .bzr.log.
34
42
 
35
43
    In general we want to log things that usually take a network round trip
128
136
        if False:
129
137
            elapsed = time.time() - before
130
138
            if result_len and elapsed > 0:
131
 
                # this is the rate of higher-level data, not the raw network
132
 
                # speed using base-10 units (see HACKING.txt).
133
 
                mutter("      %9.03fs %8dkB/s"
134
 
                       % (elapsed, result_len/elapsed/1000))
 
139
                # this is the rate of higher-level data, not the raw network speed
 
140
                mutter("      %9.03fs %8dKB/s" % (elapsed, result_len/elapsed/1024))
135
141
            else:
136
142
                mutter("      %9.03fs" % (elapsed))
137
143
        return return_result
148
154
        return t
149
155
 
150
156
 
 
157
class LogDecoratorServer(DecoratorServer):
 
158
    """Server for testing."""
 
159
 
 
160
    def get_decorator_class(self):
 
161
        return TransportLogDecorator
 
162
 
 
163
 
151
164
def get_test_permutations():
152
165
    """Return the permutations to be used in testing."""
153
 
    from bzrlib.tests import test_server
154
 
    return [(TransportLogDecorator, test_server.LogDecoratorServer)]
 
166
    return [(TransportLogDecorator, LogDecoratorServer)]