~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/log.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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.decorator import (
30
 
    TransportDecorator,
31
 
    )
32
 
from bzrlib.transport.trace import (
33
 
    DecoratorServer,
34
 
    TransportTraceDecorator,
35
 
    )
36
 
 
37
 
 
38
 
 
39
 
 
40
 
class TransportLogDecorator(TransportDecorator):
 
29
from bzrlib.transport import decorator
 
30
 
 
31
 
 
32
class TransportLogDecorator(decorator.TransportDecorator):
41
33
    """Decorator for Transports that logs interesting operations to .bzr.log.
42
34
 
43
35
    In general we want to log things that usually take a network round trip
136
128
        if False:
137
129
            elapsed = time.time() - before
138
130
            if result_len and elapsed > 0:
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))
 
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))
141
135
            else:
142
136
                mutter("      %9.03fs" % (elapsed))
143
137
        return return_result
154
148
        return t
155
149
 
156
150
 
157
 
class LogDecoratorServer(DecoratorServer):
158
 
    """Server for testing."""
159
 
 
160
 
    def get_decorator_class(self):
161
 
        return TransportLogDecorator
162
 
 
163
 
 
164
151
def get_test_permutations():
165
152
    """Return the permutations to be used in testing."""
166
 
    return [(TransportLogDecorator, LogDecoratorServer)]
 
153
    from bzrlib.tests import test_server
 
154
    return [(TransportLogDecorator, test_server.LogDecoratorServer)]