~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-13 06:08:53 UTC
  • mfrom: (4737.1.1 merge-2.0-into-devel)
  • Revision ID: pqm@pqm.ubuntu.com-20091013060853-erk2aaj80fnkrv25
(andrew) Merge lp:bzr/2.0 into lp:bzr, including fixes for #322807,
        #389413, #402623 and documentation improvements.

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
16
16
 
17
17
"""Transport decorator that logs transport operations to .bzr.log."""
18
18
 
19
 
from __future__ import absolute_import
20
19
 
21
20
# see also the transportstats plugin, which gives you some summary information
22
21
# in a machine-readable dump
27
26
import types
28
27
 
29
28
from bzrlib.trace import mutter
30
 
from bzrlib.transport import decorator
31
 
 
32
 
 
33
 
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):
34
41
    """Decorator for Transports that logs interesting operations to .bzr.log.
35
42
 
36
43
    In general we want to log things that usually take a network round trip
129
136
        if False:
130
137
            elapsed = time.time() - before
131
138
            if result_len and elapsed > 0:
132
 
                # this is the rate of higher-level data, not the raw network
133
 
                # speed using base-10 units (see HACKING.txt).
134
 
                mutter("      %9.03fs %8dkB/s"
135
 
                       % (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))
136
141
            else:
137
142
                mutter("      %9.03fs" % (elapsed))
138
143
        return return_result
149
154
        return t
150
155
 
151
156
 
 
157
class LogDecoratorServer(DecoratorServer):
 
158
    """Server for testing."""
 
159
 
 
160
    def get_decorator_class(self):
 
161
        return TransportLogDecorator
 
162
 
 
163
 
152
164
def get_test_permutations():
153
165
    """Return the permutations to be used in testing."""
154
 
    from bzrlib.tests import test_server
155
 
    return [(TransportLogDecorator, test_server.LogDecoratorServer)]
 
166
    return [(TransportLogDecorator, LogDecoratorServer)]